| View previous topic :: View next topic |
| Author |
Message |
zile Advanced Cheater
Reputation: 0
Joined: 11 Jul 2009 Posts: 75
|
Posted: Sat Apr 10, 2010 7:14 am Post subject: [C++] DialogBoxes and DLLs |
|
|
Hi, can you help me with this problem?
I made a DLL and used DialogBox(...) to show the dialogbox, but nothing shows up, however, the thread of DlgProc is made and is working, its just that the window is not there...ive added resources and all
tell me if u need to see the source
thanks..
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sat Apr 10, 2010 7:44 am Post subject: |
|
|
| i need to see the source
|
|
| Back to top |
|
 |
zile Advanced Cheater
Reputation: 0
Joined: 11 Jul 2009 Posts: 75
|
Posted: Sat Apr 10, 2010 8:35 am Post subject: |
|
|
| Quote: |
#include <windows.h>
#include "stdafx.h"
#include "BaseScanner.h"
#include "resource.h"
BOOL CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
//UNREFERENCED_PARAMETER(lParam);
switch(uMsg)
{
case WM_INITDIALOG:
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDCOMPARE:
EndDialog(hWnd, IDCOMPARE);
break;
case IDRECORD:
EndDialog(hWnd, IDCOMPARE);
break;
}
break;
case WM_CLOSE: // PRESS X close
EndDialog(hWnd, 0);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return FALSE;
}
return 0;
}
//Show Dialogue
DWORD WINAPI MainWin( HMODULE hModule){
Sleep(500);
DialogBox(hModule, MAKEINTRESOURCE(IDD_BASESCANNER), NULL, (DLGPROC)DlgProc);
ExitThread(0);
return 0;
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hModule);
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)MainWin, hModule, 0, NULL);
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
|
BaseScanner.rc + resource.h are made with resedit
im using vc++ 2008 express edition
i did this following kitterz trainer's source
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sat Apr 10, 2010 9:13 am Post subject: |
|
|
dialogprocs should return true if you processed the message. at the moment your wm_initdialog case is returning false after you process it. you need to replace the return 0 at the end of your dialogproc with return true
| Code: | case IDCOMPARE:
EndDialog(hWnd, IDCOMPARE);
break;
case IDRECORD:
EndDialog(hWnd, IDCOMPARE);
break;
}
break; |
can be replaced with :
| Code: | case IDCOMPARE:
case IDRECORD:
EndDialog(hWnd, IDCOMPARE);
break; |
there is no need to handle wm_destroy, wm_close will handle the cases you are interested in.
also fix your bracketing it's nasty.
and at the end of your mainwin, there is no need for exitthread(). when the thread returns, it returns to rtlexituserthread(). instead you should use freelibraryandexitthread()
|
|
| Back to top |
|
 |
zile Advanced Cheater
Reputation: 0
Joined: 11 Jul 2009 Posts: 75
|
Posted: Sat Apr 10, 2010 9:33 am Post subject: |
|
|
thanks! got it to work now, strange since some tutorials ive been reading uses return 0 lol
and i just paste my code into the quote and the brackets become like that lol
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sat Apr 10, 2010 9:50 am Post subject: |
|
|
| zile wrote: | thanks! got it to work now, strange since some tutorials ive been reading uses return 0 lol
and i just paste my code into the quote and the brackets become like that lol |
and there is your problem. you shouldn't just follow what you think tutorials are trying to tell you. actually take the time to look up the documentation for each function/callback on msdn
|
|
| Back to top |
|
 |
|