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 


[help] few question regarding to c++ dialog

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Bizarro
I post too much
Reputation: 0

Joined: 01 May 2007
Posts: 2648

PostPosted: Fri Apr 04, 2008 2:32 pm    Post subject: [help] few question regarding to c++ dialog Reply with quote

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 Razz

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
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Fri Apr 04, 2008 4:36 pm    Post subject: Reply with quote

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

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Fri Apr 04, 2008 7:51 pm    Post subject: Reply with quote

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
View user's profile Send private message
Bizarro
I post too much
Reputation: 0

Joined: 01 May 2007
Posts: 2648

PostPosted: Sat Apr 05, 2008 1:34 am    Post subject: Reply with quote

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

Joined: 10 Sep 2007
Posts: 197
Location: Colorado

PostPosted: Sat Apr 05, 2008 6:33 am    Post subject: Reply with quote

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
View user's profile Send private message
Bizarro
I post too much
Reputation: 0

Joined: 01 May 2007
Posts: 2648

PostPosted: Sat Apr 05, 2008 11:31 am    Post subject: Reply with quote

great, this comes in handy:P

now all i need is to complete the user input Very Happy, 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
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sat Apr 05, 2008 3:28 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Bizarro
I post too much
Reputation: 0

Joined: 01 May 2007
Posts: 2648

PostPosted: Sat Apr 05, 2008 10:35 pm    Post subject: Reply with quote

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
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sun Apr 06, 2008 3:23 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
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