Thread: Creating button windows

  1. #1
    Registered User kakayoma's Avatar
    Join Date
    Jul 2009
    Location
    Dallas, Texas
    Posts
    42

    Question Creating button windows

    I have a few button windows and on wm_create i create these with createwindow() function and apply bitmaps to them.
    when someone clicks on one of these bitmaps i destroy about 90% of them and when someone clicks on the remaining button i must recreate all of the buttons when i try this the project compiles without errors but when i click on the button which recreates the buttons it tells me an unhandled win32 exception happened and the application closes.


    How do i make this work??????????

    Vista - Something We all Love to Hate.

  2. #2
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    You have posted no source code, or even the error that you get.

    Good Job.

  3. #3
    Ex scientia vera
    Join Date
    Sep 2007
    Posts
    477
    Quote Originally Posted by valaris View Post
    You have posted no source code, or even the error that you get.

    Good Job.
    QFT.
    "What's up, Doc?"
    "'Up' is a relative concept. It has no intrinsic value."

  4. #4
    Registered User kakayoma's Avatar
    Join Date
    Jul 2009
    Location
    Dallas, Texas
    Posts
    42

    Exclamation

    Maybe you should read before posting it clearly says i used createwindow() from inside the windows proc but if you want it any way here:




    Code:
    void Createwins()
    {
         hButtona = CreateWindowEx (0,"BUTTON",
    "",
    WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_BITMAP,
    35,
    38,
    40,
    40,
    hwnd,
    (HMENU)IDB_BUTTON1,
    ((LPCREATESTRUCT) lParam)->hInstance,
    NULL);
    
    /* Set the button image */
    SendMessage(hButtona,
    BM_SETIMAGE,
    IMAGE_BITMAP,
    (LPARAM)LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_ONE)));
    (and 15 more similar buttons)
    (this is inside windowsproc) 
    
    if (LOWORD(wParam) == IDB_BUTTON17 &&
    HIWORD(wParam) == BN_CLICKED &&
    (HWND) lParam == hButtonx)
    {
    createwins();
    }

    Vista - Something We all Love to Hate.

  5. #5
    Registered User
    Join Date
    Dec 2006
    Location
    Scranton, Pa
    Posts
    252
    You really don't need to destroy, then recreate your button cntrls. Just show/hide them.

  6. #6
    Registered User kakayoma's Avatar
    Join Date
    Jul 2009
    Location
    Dallas, Texas
    Posts
    42
    How do i hide them??

    Vista - Something We all Love to Hate.

  7. #7
    Registered User
    Join Date
    Dec 2006
    Location
    Scranton, Pa
    Posts
    252
    Code:
       ShowWindow(hMyButton,SW_HIDE);
                  
                 ShowWindow(hMyButton,SW_SHOW);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BN_CLICKED, change button style
    By bennyandthejets in forum Windows Programming
    Replies: 13
    Last Post: 07-05-2010, 11:42 PM
  2. Multiple Top Level Windows
    By quark_77 in forum Windows Programming
    Replies: 0
    Last Post: 07-13-2008, 02:32 PM
  3. Just starting Windows Programming, School me!
    By Shamino in forum Windows Programming
    Replies: 17
    Last Post: 02-22-2008, 08:14 AM
  4. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  5. Windows 98/2000 programming in Windows XP
    By Bill83 in forum Windows Programming
    Replies: 3
    Last Post: 07-22-2005, 02:16 PM