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 


[C++] Icon in a DLL GUI

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Wintermoot
Expert Cheater
Reputation: 0

Joined: 08 Nov 2007
Posts: 198

PostPosted: Tue Nov 11, 2008 7:37 pm    Post subject: [C++] Icon in a DLL GUI Reply with quote

Code:
void Window()
{
   HWND hWnd;
   MSG iMsg;
   WNDCLASSEX wc;

   ZeroMemory(&wc,sizeof(WNDCLASSEX));

   wc.cbSize = sizeof(WNDCLASSEX);
   wc.style = CS_HREDRAW | CS_VREDRAW;
   wc.cbClsExtra = 0;
   wc.cbWndExtra = 0;
   wc.hbrBackground = (HBRUSH)COLOR_BTNHIGHLIGHT;
   wc.hIcon = LoadIcon(NULL,IDI_APPLICATION);
   wc.hCursor = LoadCursor(NULL,IDC_ARROW);
   wc.hInstance = Module;
   wc.lpfnWndProc = WndProc;
   wc.lpszMenuName = NULL;
   wc.lpszClassName = _T("Wintermute");
   wc.hIconSm = LoadIcon(NULL,IDI_APPLICATION);

   if (!RegisterClassEx(&wc)){
      MessageBox(0,_T("Failed"),0,0);
      ExitWindow();
   }
   hWnd = CreateWindowEx(WS_EX_APPWINDOW | WS_EX_DLGMODALFRAME,_T("Wintermute"),_T("GrandChase Trainer"),WS_SYSMENU,CW_USEDEFAULT,CW_USEDEFAULT,200,130,0,0,Module,0);
   ShowWindow(hWnd,SW_SHOWNORMAL);
   UpdateWindow(hWnd);

   while (GetMessage(&iMsg,0,0,0))
   {
      TranslateMessage(&iMsg);
      DispatchMessage(&iMsg);
   }
   ExitWindow();
}


Basically, I have an icon added as a resource. This icon is called Icon_1.ico. My problem is that I have no clue how to do it. I have tried changing wc.hIcon and wc.hIconSm but, it doesn't change anything...

The GUI otherwise works...
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Tue Nov 11, 2008 7:43 pm    Post subject: Reply with quote

wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDC_ICON1);

* - Italics: Change them to your identifiers that hold the instance and resource ID.

_________________
Back to top
View user's profile Send private message
Wintermoot
Expert Cheater
Reputation: 0

Joined: 08 Nov 2007
Posts: 198

PostPosted: Tue Nov 11, 2008 8:05 pm    Post subject: Reply with quote

Code:

#define IDI_ICON1 L"GC_Icon.ico"
...
HMODULE Module;
...
void Window()
{
   HWND hWnd;
   MSG iMsg;
   WNDCLASSEX wc;

   ZeroMemory(&wc,sizeof(WNDCLASSEX));

   wc.hInstance = Module;
   wc.cbSize = sizeof(WNDCLASSEX);
   wc.style = CS_HREDRAW | CS_VREDRAW;
   wc.cbClsExtra = 0;
   wc.cbWndExtra = 0;
   wc.hbrBackground = (HBRUSH)COLOR_BTNHIGHLIGHT;
   wc.hIcon = LoadIcon(Module,IDI_ICON1);
   wc.hCursor = LoadCursor(NULL,IDC_ARROW);
   wc.lpfnWndProc = WndProc;
   wc.lpszMenuName = NULL;
   wc.lpszClassName = _T("Wintermute");
   wc.hIconSm = LoadIcon(Module,IDI_ICON1);//LoadIcon(NULL,IDI_APPLICATION);

   if (!RegisterClassEx(&wc)){
      MessageBox(0,_T("Failed"),0,0);
      ExitWindow();
   }
   hWnd = CreateWindowEx(WS_EX_APPWINDOW | WS_EX_DLGMODALFRAME,_T("Wintermute"),_T("GrandChase Trainer"),WS_SYSMENU,CW_USEDEFAULT,CW_USEDEFAULT,200,130,0,0,Module,0);
   ShowWindow(hWnd,SW_SHOWNORMAL);
   UpdateWindow(hWnd);

   while (GetMessage(&iMsg,0,0,0))
   {
      TranslateMessage(&iMsg);
      DispatchMessage(&iMsg);
   }
   ExitWindow();
}
...
BOOL APIENTRY DllMain( HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
{
   if (ul_reason_for_call == DLL_PROCESS_ATTACH)
   {
      Module = hModule;
      CreateThread(0,0,(LPTHREAD_START_ROUTINE)&Window,0,0,0);
   }
   return TRUE;
}


For some reason, this does not work. To add the icon, I right-clicked the project Add->Existing->GC_Icon.ico

I am still rather new to CreateWindow and all that but, basically, once this icon is added, the trainer is finished so, I would love you for numerous years if you could tell me where I am screwing...
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Tue Nov 11, 2008 8:24 pm    Post subject: Reply with quote

Take out WS_EX_DLGMODALFRAME from the dwExStyle and the icon will come up Wink
_________________
Back to top
View user's profile Send private message
nwongfeiying
Grandmaster Cheater
Reputation: 2

Joined: 25 Jun 2007
Posts: 695

PostPosted: Tue Nov 11, 2008 10:31 pm    Post subject: Reply with quote

That'll be cool to have lurc on our dev team.
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