Thread: Buttons

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Add this to the beginning of the file:
    Code:
    #define IDB_BUTTON1 50001
    A code example, place it in your WM_CREATE:
    Code:
    HWND button;
    button=CreateWindowEx(0,"Button","Buttontext", WS_BORDER | WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 1, 1, 100, 23, hwnd, (HMENU)IDB_BUTTON1, GetModuleHandle(NULL), NULL);
    And to change the font you can use:
    Code:
    HFONT hf;
    long lf;
    lf = -MulDiv(12, GetDeviceCaps(hdc, LOGPIXELSY), 72);
    hf = CreateFont(lf, 0, 0, 0, FW_MEDIUM, FALSE, 0, 0, 0, 0, 0, 0, 0, "Times New Roman");
    SendMessage(button,WM_SETFONT,(WPARAM)hf,TRUE);
    You can use any other font instead of Times New Roman.
    And if you want it to do something, when you click on the button, add this code to your message switch:
    Code:
    case WM_COMMAND:
    switch(wParam){
    case IDB_BUTTON1:
    MessageBox(hwnd,"You clicked the button","Message",MB_OK | MB_INFORMATION);
    return 0;
    }
    break;
    Last edited by maxorator; 09-30-2005 at 01:29 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 04-09-2009, 02:31 AM
  2. Ownerdraw buttons (2)
    By maes in forum Windows Programming
    Replies: 7
    Last Post: 09-11-2003, 05:50 AM
  3. Radio Buttons in Visual C++ 6
    By Ripper1 in forum Windows Programming
    Replies: 22
    Last Post: 05-16-2003, 07:54 AM
  4. (Ken Fitlike) buttons
    By jdinger in forum C++ Programming
    Replies: 4
    Last Post: 03-15-2002, 01:21 PM
  5. Grouping radio buttons
    By Bazz in forum Windows Programming
    Replies: 1
    Last Post: 08-28-2001, 07:15 AM