Thread: Windows GUI

  1. #1
    Registered User Spectrum48k's Avatar
    Join Date
    May 2002
    Posts
    66

    Question Windows GUI

    How does C code become windows program ? do you design your app windows in Visual studio and paste code on buttons sort of like creating hyperlinks and hotspots on a web page ?

    just curious

    thanx..
    its alive... its ALIVE... ITS...AL...IIIVE !!!!!!!!!

  2. #2
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    For dialog style applications, pretty much.
    The world is waiting. I must leave you now.

  3. #3
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533
    I am not sure I understand your question quite well but perhaps this might help
    NeHe OpenGL Programming
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

  4. #4
    Registered User
    Join Date
    May 2002
    Posts
    7
    im not 100% sure but if you are talking about your code and wanting it to work in windows, I think you have to add a windows header file to access that stuff. Havn't learned it myself yet but that will be to come.

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    142
    or probably this would be the answer to your mystical question,

    win32api is made using the c language, so by using these win32 functions, your c code becomes a win32 program,

  6. #6
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    Code:
    #include <windows.h> 
    
    LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM); 
    char szWinName[] = "MyWin"; 
    
    int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst, 
    LPSTR lpszArgs, int nWinMode) 
    { 
            HWND hwnd; 
            MSG msg; 
            WNDCLASSEX wcl; 
    
            wcl.cbSize = sizeof(WNDCLASSEX); 
    
            wcl.hInstance = hThisInst; 
            wcl.lpszClassName = szWinName; 
            wcl.lpfnWndProc = WindowFunc; 
            wcl.style = 0; 
    
            wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION); 
            wcl.hIconSm = NULL; 
            wcl.hCursor = LoadCursor(NULL, IDC_ARROW); 
    
            wcl.lpszMenuName = NULL; 
            wcl.cbClsExtra = 0; 
            wcl.cbWndExtra = 0; 
    
            if(!RegisterClassEx(&wcl)) return 0; 
    
            hwnd = CreateWindow( 
            szWinName, 
            "A Window", 
            WS_OVERLAPPEDWINDOW, 
            CW_USEDEFAULT, 
            CW_USEDEFAULT, 
            CW_USEDEFAULT, 
            CW_USEDEFAULT, 
            NULL, 
            NULL, 
            hThisInst, 
            NULL); 
    
            ShowWindow(hwnd, nWinMode); 
            UpdateWindow(hwnd); 
    
            while(GetMessage(&msg, NULL, 0, 0)) 
            { 
                    TranslateMessage(&msg); 
                    DispatchMessage(&msg); 
            } 
            return msg.wParam; 
    } 
    
    
    LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, 
    WPARAM wParam, LPARAM lParam) 
    { 
            switch(message) 
            { 
                    case WM_DESTROY: 
                    PostQuitMessage(0); 
                    break; 
                    default: 
                    return DefWindowProc(hwnd, message, wParam, lParam); 
            } 
    return 0; 
    }
    The world is waiting. I must leave you now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ gui for windows where to start
    By prixone in forum Windows Programming
    Replies: 2
    Last Post: 12-16-2006, 11:48 PM
  2. Windows GUI Preprocessing
    By Jaken Veina in forum Windows Programming
    Replies: 5
    Last Post: 07-22-2005, 01:22 PM
  3. Linux's GUI slower than windows'....
    By Nutshell in forum A Brief History of Cprogramming.com
    Replies: 34
    Last Post: 02-16-2002, 08:47 PM
  4. GUI Programming :: C++ Exclusive
    By kuphryn in forum C++ Programming
    Replies: 5
    Last Post: 01-25-2002, 03:22 PM
  5. C++: Reference Book, GUI, Networking & Beyond
    By kuphryn in forum C++ Programming
    Replies: 4
    Last Post: 11-10-2001, 08:03 PM