Advertisement

Why cant I create controls after I have used destroyWindow??..

Started by February 24, 2002 11:43 AM
9 comments, last by Mullvad 22 years, 6 months ago
Why?? Heres some code where the create part doesnt work.. And dont wore about the if`s I have things that make the value correct to run create.
  if (EfterSG == 1)
{

DestroyWindow(hKnappNEW);
DestroyWindow(hKnappRESUME);
DestroyWindow(hKnappEXIT);
DestroyWindow(hTextMAINMENU);


if (Skapar_saker == 1)
{
hKnappWest = CreateWindowEx(WS_EX_CLIENTEDGE, "BUTTON", "West",
            WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP,
            150, 250, 50, 50, hwnd, (HMENU)ID_WEST_BUTTON, ´    GetModuleHandle(NULL), NULL);
        if(hKnappWest == NULL)
            MessageBox(hwnd, "Could not create push button.", "Error", MB_OK | MB_ICONERROR);
Skapar_saker = 2;
}
}]  
Mullvad Edited by - Mullvad on February 25, 2002 1:27:59 PM Edited by - Mullvad on February 25, 2002 1:29:35 PM
Mullvad
Is ID_WEST_BUTTON actually a menu resource, or is it the button image?

(Read the site FAQ. It contains information on how to format code in your posts).

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
Advertisement
It is a button that is created directly at the window and the controls I using destroy window on is also button thats directly created at the window
Mullvad
I dont think you can change the resource ID of a button into a handle to a menu.

Invader X
Invader''s Realm
I dont know what you talk about I just trying to create a button after a have deleted some when using DestroyWindow but it doesnt work to create a new but the old one dissapers. Why doesnt the new West button come up??

Mullvad
Mullvad
I''m sorry, after reading the documentation I realize that the hMenu parameter of CreateWindowEx should allow you to use (HMENU)ID_WEST_BUTTON.

Invader X
Invader''s Realm
Advertisement
Yeah but can you help me with my problem??

Mullvad
Mullvad
I''ll have to create a new project and play around because I don''t see errors. (Hopefully somebody will help out here before that since I wont have time to even try till Friday)

What is the formatted message returned if you use GetLastError() and FormatMessage() when the button fails to be created?

Invader X
Invader''s Realm
It is one more thing I want to ad and that is when I am using DestroyWindow to delet my main window then I get a error message and the program I am using(borland c++ 5.01) destroys and I have to restart the program and begin from the last saved.

Mullvad
Mullvad
What is the error?

Invader X
Invader''s Realm

This topic is closed to new replies.

Advertisement