Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Delay when creating a window.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
DebugMe
Newbie cheater
Reputation: 0

Joined: 29 May 2007
Posts: 20

PostPosted: Tue Feb 12, 2008 12:51 pm    Post subject: Delay when creating a window. Reply with quote

Hi guys, I'm having a problem when creating a window. The window appears, but it takes time before it fully appears in the task bar, anyone know what's the problem?

Oh and 1 more thing, in VS2005 I set the option to Unicode so should I use CreateWindowEx since it will be changed to CreateWindowExW, or directly use CreateWindowExW?

Thanks, here's the code:

Code:
#include <windows.h>

#define BTN_SHOWMESSAGE        1
#define EDT_MESSAGE            2

LRESULT CALLBACK WndProc( HWND hWnd , UINT message , WPARAM wParam , LPARAM lParam)
{
    switch(message){
    case WM_COMMAND:
        if(LOWORD(wParam)==BTN_SHOWMESSAGE)
      {
            wchar_t TextBuffer[256];
            GetDlgItemText(hWnd, EDT_MESSAGE, TextBuffer, 256);
            MessageBox(hWnd, TextBuffer, TEXT("Welcome"),MB_OK);
        }
        break;

      case WM_CLOSE:
            DestroyWindow(hWnd);
        break;
        case WM_DESTROY:
            PostQuitMessage(0);
        break;

    }
    return DefWindowProc(hWnd,message,wParam,lParam);
}

INT WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow )
{
   WNDCLASSEX wc;
   MSG msg;
   HWND hWnd;
   HWND text;
    HWND edit;
   HWND button;

    // Create A Window Class Structure
    wc.cbClsExtra = 0;
    wc.cbSize = sizeof(wc);
    wc.cbWndExtra = 0;
    wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
    wc.hCursor = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
    wc.hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_HAND));
    wc.hIconSm = LoadIcon(NULL, MAKEINTRESOURCE(IDI_HAND));
    wc.hInstance = GetModuleHandle(NULL);
    wc.lpfnWndProc = WndProc;
    wc.lpszClassName = TEXT("My Class");
    wc.lpszMenuName = NULL;
    wc.style = CS_VREDRAW|CS_HREDRAW|CS_OWNDC;
   
    // Register Window Class
    if(!RegisterClassEx(&wc))
    {
        MessageBox(NULL, TEXT("Window Registration Failed!"), TEXT("Error!"),
            MB_ICONEXCLAMATION | MB_OK);
        return 0;
    }

   
    // Create a Window
        hWnd = CreateWindowEx(0,
        TEXT("My Class"), TEXT("Window"),
        WS_OVERLAPPEDWINDOW, 100,100,400,200,
        NULL,NULL,wc.hInstance,0);

   if(hWnd == NULL)
    {
        MessageBox(NULL, TEXT("Window Creation Failed!"), TEXT("Error!"),
            MB_ICONEXCLAMATION | MB_OK);
        return 0;
    }


    // Create a label
        text = CreateWindowEx(0,
        TEXT("STATIC"), TEXT("Welcome!"),
        WS_CHILD|WS_VISIBLE, 10,10,100,20,
        hWnd,NULL,NULL,0);

    // Create a edit box
        edit = CreateWindowEx(0,
        TEXT("EDIT"), TEXT("Your Message..."),
        WS_CHILD|WS_VISIBLE|WS_BORDER, 10,50,370,20,
        hWnd,(HMENU)EDT_MESSAGE,NULL,0);
   
    // Create a button
        button = CreateWindowEx(0,
        TEXT("BUTTON"), TEXT("Show Message"),
        WS_CHILD|WS_VISIBLE, 10,90,100,20,
        hWnd,(HMENU)BTN_SHOWMESSAGE,NULL,0);
   
    ShowWindow(hWnd,nCmdShow);
   UpdateWindow(hWnd);

   
    // Message Loop
   
    while(GetMessage(&msg,hWnd,0,0)>0)
   {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
   
     return 0;

}
Back to top
View user's profile Send private message
Antti
Grandmaster Cheater Supreme
Reputation: -1

Joined: 24 Nov 2006
Posts: 1110

PostPosted: Tue Feb 12, 2008 12:57 pm    Post subject: Reply with quote

error or what?
Back to top
View user's profile Send private message
Renkokuken
GO Moderator
Reputation: 4

Joined: 22 Oct 2006
Posts: 3249

PostPosted: Tue Feb 12, 2008 1:17 pm    Post subject: Reply with quote

I recommend you use the full API, since if you ever change the settings, the definitions won't change.

You don't need to use TEXT(), you could just use the L operator instead.
Code:
L"Hello"


No delay for the window creation on my computer, if you're running from the IDE, it might be slowed down a tad.

Oh yes, I've also sent you a PM about the console. If you're interested, I'll keep you updated on it.
Back to top
View user's profile Send private message
DebugMe
Newbie cheater
Reputation: 0

Joined: 29 May 2007
Posts: 20

PostPosted: Tue Feb 12, 2008 3:10 pm    Post subject: Reply with quote

Renkokuken wrote:
I recommend you use the full API, since if you ever change the settings, the definitions won't change.

You don't need to use TEXT(), you could just use the L operator instead.
Code:
L"Hello"


Alright, thanks for the suggestions.


Renkokuken wrote:

No delay for the window creation on my computer, if you're running from the IDE, it might be slowed down a tad.


Humm that's weird, that's what I'm getting. I'm running the .exe from the folder. It stays like that for about 2 seconds.


Renkokuken wrote:


Oh yes, I've also sent you a PM about the console. If you're interested, I'll keep you updated on it.


It would be great :)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites