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++] DialogBoxes and DLLs

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

Joined: 11 Jul 2009
Posts: 75

PostPosted: Sat Apr 10, 2010 7:14 am    Post subject: [C++] DialogBoxes and DLLs Reply with quote

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
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sat Apr 10, 2010 7:44 am    Post subject: Reply with quote

i need to see the source
Back to top
View user's profile Send private message
zile
Advanced Cheater
Reputation: 0

Joined: 11 Jul 2009
Posts: 75

PostPosted: Sat Apr 10, 2010 8:35 am    Post subject: Reply with quote

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
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sat Apr 10, 2010 9:13 am    Post subject: Reply with quote

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
View user's profile Send private message
zile
Advanced Cheater
Reputation: 0

Joined: 11 Jul 2009
Posts: 75

PostPosted: Sat Apr 10, 2010 9:33 am    Post subject: Reply with quote

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
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sat Apr 10, 2010 9:50 am    Post subject: Reply with quote

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
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