Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. I check, compile and run every program. Contact me at: aviboots(AT)netvision.net.il
Hostgator 1 Penny

BlueHost Web Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

getflywheel wordpress hosting


Distribute your Resume to 500+ Job Boards & Recruiters


6,846 questions

9,748 answers

573 users

How to Create Window with button in C Win32 API

Directory of Wholesale Companies and Dropship Suppliers | SaleHoo

55 views
asked Dec 17, 2014 by avibootz
edited Dec 17, 2014 by avibootz

1 Answer

0 votes
#include <windows.h>

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

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
  MSG  msg ;    
  HWND hwnd;

  WNDCLASS wc = {0};
    
  wc.lpszClassName = TEXT("Window");
  wc.hInstance     = hInstance ;
  wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
  wc.lpfnWndProc   = WndProc;
 
  RegisterClass(&wc);
  hwnd = CreateWindow(wc.lpszClassName, TEXT("Window Title"),
                      WS_OVERLAPPEDWINDOW | WS_VISIBLE,
                      100, 100, 350, 250, NULL, NULL, hInstance, NULL);  

  while(GetMessage(&msg, NULL, 0, 0))
  {
    DispatchMessage(&msg);
  }
  return (int) msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
  switch(msg)  
  {
        case WM_CREATE:
        {
                CreateWindow(TEXT("button"), TEXT("Ok"),  WS_VISIBLE | WS_CHILD ,
                             100, 100, 90, 30, hwnd, (HMENU) 1, NULL, NULL);  
                break;    
        }
        case WM_DESTROY:
        {
                PostQuitMessage(0);
                return 0;
        }
  }
  return DefWindowProc(hwnd, msg, wParam, lParam);
}







answered Dec 17, 2014 by avibootz
...