当前位置: 代码迷 >> C语言 >> 如何学习windows编程好?
  详细解决方案

如何学习windows编程好?

热度:278   发布时间:2008-05-01 13:22:07.0
如何学习windows编程好?
我的意思是学习c也好,c++也好,归宿大部分是要转到window编程(或Linux编程)去。
是要等到很精通c,c++后才能开始吗?对它们只是有个概念性的了解后就去开始
怎么样呢?
搜索更多相关的解决方案: windows  Linux  学习  概念性  归宿  

----------------解决方案--------------------------------------------------------
把基础打好..那些东些你把基础弄好后,见到就会用了..还是多学算法吧...
----------------解决方案--------------------------------------------------------
天天打基础,没有实际的应用,很打击自信心的啊!最终导致的结果是越学越没劲
----------------解决方案--------------------------------------------------------
你自己动手写啊..那么多高级语言设计.找本看看..其实基础里面也很好玩的...windows的高级编程就消息机制...其它都是c的基础..如果觉得基础没意思..你到燕子论坛看看..很多好玩的东西
#include <windows.h>
        

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
        

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
        
                   PSTR szCmdLine, int iCmdShow)
        
{
        
    static TCHAR szAppName[] = TEXT ("HelloWin") ;
        
    HWND   hwnd ;
        
    MSG    msg ;
        
    WNDCLASS wndclass ;
        

   wndclass.style        = CS_HREDRAW | CS_VREDRAW ;
        
   wndclass.lpfnWndProc  = WndProc ;
        
    wndclass.cbClsExtra   = 0 ;
        
    wndclass.cbWndExtra   = 0 ;
        
    wndclass.hInstance    = hInstance ;
        
    wndclass.hIcon        = LoadIcon (NULL, IDI_APPLICATION) ;
        
  wndclass.hCursor      = LoadCursor (NULL, IDC_ARROW) ;
        
   wndclass.hbrBackground= (HBRUSH) GetStockObject (WHITE_BRUSH) ;
        
  wndclass.lpszMenuName = NULL ;
        
  wndclass.lpszClassName= szAppName ;
        

    if (!RegisterClass (&wndclass))
        
    {
        
            MessageBox (  NULL, TEXT ("This program requires Windows NT!"),
        
                                  szAppName, MB_ICONERROR) ;
        
            return 0 ;
        
    }
        
    hwnd = CreateWindow( szAppName,      // window class name
        
                   TEXT ("The Hello Program"),   // window caption
        
                   WS_OVERLAPPEDWINDOW,  // window style
        
                   CW_USEDEFAULT,// initial x position
        
                   CW_USEDEFAULT,// initial y position
        
                   CW_USEDEFAULT,// initial x size
        
                   CW_USEDEFAULT,// initial y size
        
                   NULL,                 // parent window handle
        
                   NULL,            // window menu handle
        
                  hInstance,   // program instance handle
        
                  NULL) ;      // creation parameters
        
   
        
    ShowWindow (hwnd, iCmdShow) ;
        
    UpdateWindow (hwnd) ;
        
   
        
    while (GetMessage (&msg, NULL, 0, 0))
        
    {
        
            TranslateMessage (&msg) ;
        
          DispatchMessage (&msg) ;
        
    }
        
    return msg.wParam ;
        
}
        

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
        
{
        
    HDC                   hdc ;
        
    PAINTSTRUCT ps ;
        
    RECT          rect ;
        
   
        
    switch (message)
        
    {
        
      

    case   WM_PAINT:
        
            hdc = BeginPaint (hwnd, &ps) ;
        
        
        
            GetClientRect (hwnd, &rect) ;
        
        
        
            DrawText (hdc, TEXT ("Hello, Windows 98!"), -1, &rect,
        
                   DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
        
                 EndPaint (hwnd, &ps) ;
        
                   return 0 ;
        
        
        
    case   WM_DESTROY:
        
            PostQuitMessage (0) ;
        
            return 0 ;
        
    }
        
  return DefWindowProc (hwnd, message, wParam, lParam) ;
        
}

[[it] 本帖最后由 sunkaidong 于 2008-5-1 13:39 编辑 [/it]]
----------------解决方案--------------------------------------------------------
#include <windows.h>
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
    static TCHAR szAppName[] = TEXT ("HelloWin") ;
    HWND     hwnd ;
    MSG      msg ;
    WNDCLASS wndclass ;
    wndclass.style        = CS_HREDRAW | CS_VREDRAW ;
    wndclass.lpfnWndProc  = WndProc ;
    wndclass.cbClsExtra   = 0 ;
    wndclass.cbWndExtra   = 0 ;
    wndclass.hInstance    = hInstance ;
    wndclass.hIcon        = LoadIcon (NULL, IDI_APPLICATION) ;
    wndclass.hCursor      = LoadCursor (NULL, IDC_ARROW) ;
    wndclass.hbrBackground= (HBRUSH) GetStockObject (WHITE_BRUSH) ;
    wndclass.lpszMenuName = NULL ;
    wndclass.lpszClassName= szAppName ;
    if (!RegisterClass (&wndclass))
    {
        MessageBox ( NULL, TEXT ("This program requires Windows NT!"),
                        szAppName, MB_ICONERROR) ;
        return 0 ;
    }
    hwnd = CreateWindow( szAppName,      // window class name
                        TEXT ("The Hello Program"),   // window caption
                        WS_OVERLAPPEDWINDOW,  // window style
                        CW_USEDEFAULT,// initial x position
                        CW_USEDEFAULT,// initial y position
                        CW_USEDEFAULT,// initial x size
                        CW_USEDEFAULT,// initial y size
                        NULL,                 // parent window handle
                        NULL,            // window menu handle
                        hInstance,   // program instance handle
                        NULL) ;      // creation parameters
    ShowWindow (hwnd, iCmdShow) ;
    UpdateWindow (hwnd) ;
    while (GetMessage (&msg, NULL, 0, 0))
    {
        TranslateMessage (&msg) ;
        DispatchMessage (&msg) ;
    }
    return msg.wParam ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    HDC         hdc ;
    PAINTSTRUCT ps ;
    RECT        rect ;
    switch (message)
    {
    case WM_PAINT:
        hdc = BeginPaint (hwnd, &ps) ;
        GetClientRect (hwnd, &rect) ;
        DrawText (hdc, TEXT ("Hello, Windows 98!"), -1, &rect,
                    DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
        EndPaint (hwnd, &ps) ;
        return 0 ;
    case WM_DESTROY:
        PostQuitMessage (0) ;
        return 0 ;
    }
    return DefWindowProc (hwnd, message, wParam, lParam) ;
}


[color=white]
----------------解决方案--------------------------------------------------------
谢谢,我把yzfy.org收藏了
----------------解决方案--------------------------------------------------------
建议楼主如果现在不急着用windows编程的话还是先把C学精了,
因为C是结构化编程的基础,学扎实了其他的都很容易上手,
很多语言写伪代码也是用类C语言,因为大部分人都会C
----------------解决方案--------------------------------------------------------
同意楼上.
----------------解决方案--------------------------------------------------------
我真的很菜 所以说什么大家不要骂我


我现在也没想明白一个问题 如果一个人不回C语言 能搞编程么

我看许多JAVA C++ VC 里面基本都是换个形式或者做个宏 什么的替换一下而已 根本还是C语言的东西
----------------解决方案--------------------------------------------------------
个人认为要找一个方向,不要什么语言都学.
----------------解决方案--------------------------------------------------------
  相关解决方案