 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Bizarro I post too much
Reputation: 0
Joined: 01 May 2007 Posts: 2648
|
Posted: Fri Apr 04, 2008 2:32 pm Post subject: [help] few question regarding to c++ dialog |
|
|
HI
with the help of wiccan's c++ dialog tut. i recently finished my first c++ DLL with a dialog as a substitute for real GUI.
i have 2 questions about the dialogs. hopefully some pros in c++ can help me out
1) i was wondering if anyone know anyway to change the color of the dialog and even add a pic/ico somewhere. it would be really great to make it look more userfriendly.
2) if i want to get a user input by adding an edit control in the dialog, how do i retreive its input as a string.
here is the main structure for the dialog.
| Code: |
BOOL CALLBACK DlgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
UNREFERENCED_PARAMETER( lParam );
switch( uMsg )
{
case WM_INITDIALOG:
//this is the first message called to the dialog when it is being created
ShowWindow( hWnd, SW_SHOW );
return TRUE;
case WM_COMMAND:
//this will handle the command buttons that are part of the dialog
...
case WM_QUIT:
case WM_DESTROY:
EndDialog( hWnd, 0 );
return TRUE;
|
it would be really great if you can explain in some detail, kinda new to c++ and dialog making:(
thank you
_________________
w8 baby.com Banner contest, Come join NOW!!
Check us out for Prize deatils |
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Fri Apr 04, 2008 4:36 pm Post subject: |
|
|
| Edit the resource, non express versions of Visual Studio come with a resource editor, or you can just use one of the 21398123 free ones floating around.
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Fri Apr 04, 2008 7:51 pm Post subject: |
|
|
| Quote: |
2) if i want to get a user input by adding an edit control in the dialog, how do i retreive its input as a string. |
GetDlgItemText - Search MSDN
I'll try to look up about #1
It involves redrawing your app.
But for the Icon.
1. Create an Icon in resource.
2. Use LoadIcon
For Pic.
Try Picture Control.
_________________
|
|
| Back to top |
|
 |
Bizarro I post too much
Reputation: 0
Joined: 01 May 2007 Posts: 2648
|
Posted: Sat Apr 05, 2008 1:34 am Post subject: |
|
|
| lurc wrote: | | Quote: |
2) if i want to get a user input by adding an edit control in the dialog, how do i retreive its input as a string. |
GetDlgItemText - Search MSDN
I'll try to look up about #1
It involves redrawing your app.
But for the Icon.
1. Create an Icon in resource.
2. Use LoadIcon
For Pic.
Try Picture Control. |
tx i will test them out
for picture control, i can't seem to put a picture there somehow o_o
btw im using VS 2008 pro.
________
Toyota MR2 specifications
Last edited by Bizarro on Tue Feb 01, 2011 11:58 am; edited 1 time in total |
|
| Back to top |
|
 |
killersamurai Expert Cheater
Reputation: 0
Joined: 10 Sep 2007 Posts: 197 Location: Colorado
|
Posted: Sat Apr 05, 2008 6:33 am Post subject: |
|
|
You would need to process the WM_PAINT message to draw a picture in the background.
| Code: |
LRESULT CALLBACK DlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
static int width, height;
static HBITMAP hPic;
HDC hDc, hCompat;
PAINTSTRUCT ps;
switch (Msg)
{
case WM_INITDIALOG:
{
hPic = LoadBitmap((HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), MAKEINTRESOURCE(IDB_BITMAP1));
RECT rect;
GetWindowRect(hWnd, &rect);
width = rect.right;
height = rect.bottom;
SetFocus(hWnd);
}
return true;
case WM_PAINT:
{
hDc = BeginPaint(hWnd, &ps);
hCompat = CreateCompatibleDC(hDc);
SelectObject(hCompat, hPic);
StretchBlt(hDc, 0, 0, width, height, hCompat, 0, 0, 505, 505, SRCCOPY);
DeleteDC(hCompat);
EndPaint(hWnd, &ps);
}
return true;
case WM_CLOSE:
EndDialog(hWnd, 0);
DeleteObject(hPic);
return true;
case WM_DESTROY:
PostQuitMessage(0);
return true;
}
return false;
}
|
This uses a .bmp that is in resource.
|
|
| Back to top |
|
 |
Bizarro I post too much
Reputation: 0
Joined: 01 May 2007 Posts: 2648
|
Posted: Sat Apr 05, 2008 11:31 am Post subject: |
|
|
great, this comes in handy:P
now all i need is to complete the user input , then im set
________
Ford Territory picture
Last edited by Bizarro on Tue Feb 01, 2011 11:58 am; edited 1 time in total |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sat Apr 05, 2008 3:28 pm Post subject: |
|
|
You can do the same with changing the background to say, black:
| Code: | void SetupBackground( HWND hWnd )
{
BITMAPINFO canvas = {0};
HBITMAP canvasBMP = NULL;
HDC canvasHDC = NULL;
HGDIOBJ canvasOBJ = NULL;
unsigned char* lpCanvasBuffer;
RECT lpRect = {0};
GetWindowRect( GetDesktopWindow(), &lpRect );
canvas.bmiHeader.biSize = sizeof(canvas.bmiHeader);
canvas.bmiHeader.biWidth = lpRect.left+lpRect.right;
canvas.bmiHeader.biHeight = lpRect.top+lpRect.bottom;
canvas.bmiHeader.biPlanes = 1;
canvas.bmiHeader.biBitCount = 32;
canvasHDC = CreateCompatibleDC( GetWindowDC( hWnd ) );
canvasBMP = CreateDIBSection( canvasHDC, &canvas, DIB_RGB_COLORS, (LPVOID*)&lpCanvasBuffer, NULL, NULL );
canvasOBJ = SelectObject( canvasHDC, canvasBMP );
SetBkColor( canvasHDC, TRANSPARENT );
memset( (void*)lpCanvasBuffer, 0x0, canvas.bmiHeader.biWidth*canvas.bmiHeader.biHeight*4 );
PAINTSTRUCT paintStruct = {0};
HDC hDisplay = BeginPaint( hWnd, &paintStruct );
BitBlt( hDisplay, 0, 0, canvas.bmiHeader.biWidth, canvas.bmiHeader.biHeight, canvasHDC, NULL, NULL, SRCCOPY );
EndPaint( hWnd, &paintStruct );
} |
This was for something I made for someone a bit ago, so change some stuff as needed. (Mostly the sizes and such.)
_________________
- Retired. |
|
| Back to top |
|
 |
Bizarro I post too much
Reputation: 0
Joined: 01 May 2007 Posts: 2648
|
Posted: Sat Apr 05, 2008 10:35 pm Post subject: |
|
|
cool tx again wiccan.
one more problem. i tried to create an edit control in the dialog to receive user input as a string[] or char[];
but somehow with GetDlgItemText, everytime i click on the edit control, the dialog auto closes. :S
i don't know whats wrong. any suggestions or example i can look up
________
buy vaporgenie
Last edited by Bizarro on Tue Feb 01, 2011 11:58 am; edited 1 time in total |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun Apr 06, 2008 3:23 am Post subject: |
|
|
| Bizarro wrote: | cool tx again wiccan.
one more problem. i tried to create an edit control in the dialog to receive user input as a string[] or char[];
but somehow with GetDlgItemText, everytime i click on the edit control, the dialog auto closes. :S
i don't know whats wrong. any suggestions or example i can look up |
Sounds like your dialog callback has a messed up case that is not breaking or returning correctly and is 'bleeding' into another case. Check your command cases and be sure that they are all closed correctly.
_________________
- Retired. |
|
| Back to top |
|
 |
|
|
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
|
|