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]Tabs
Goto page 1, 2  Next
 
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: Mon Apr 26, 2010 7:48 am    Post subject: [Help]Tabs Reply with quote

Anyone mind giving me an example of using tabs in dialogs? I can only find MFC stuff...which im not using, i made my 4 dialog resources, and coded the first dialog with 4 tabs , do i need to create another CALLBACK for each dialog?
So then, i use WM_NOTIFY and use ShowWindow to hide and show each dialog, but what function should i use to make the pos the same?

and i need some off-section help, this game im trying to hack has functions like
IntToFloat
WriteSingleValue
so, when i right click most address, and see what writes to it, it goes to these functions,
i tried breakpointing the start of the function, but i keeps pausing because it is always called. so, how can i get the address calling the function ON the address i want? is the only way using olly and ctrl+r and browse 1 by 1?
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Mon Apr 26, 2010 12:01 pm    Post subject: Reply with quote

this page will tell you everything you want to know about tabs, including examples :
http://msdn.microsoft.com/en-us/library/bb760548(VS.85).aspx

answer to your game question is to look at the return address on the stack.
Back to top
View user's profile Send private message
zile
Advanced Cheater
Reputation: 0

Joined: 11 Jul 2009
Posts: 75

PostPosted: Tue Apr 27, 2010 6:22 am    Post subject: Reply with quote

im using dialogbox, so.. should i use CreateWindow(...) instead of DialogBox(...)...? to be able to get the hwnd of all dialogs so that i can show and hide it ... this is confusing x.x


but the problem is i cant look at the return with breakpoints... i cant move to trigger the value of the specific address to change when the game is constantly pausing ( function is called for many other stuff )
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Tue Apr 27, 2010 10:18 am    Post subject: Reply with quote

no you can use dialogs too. i have code, but it's in masm32 so probably not too useful to you.

post your project here and i'll take a look
Back to top
View user's profile Send private message
zile
Advanced Cheater
Reputation: 0

Joined: 11 Jul 2009
Posts: 75

PostPosted: Wed Apr 28, 2010 1:18 am    Post subject: Reply with quote

Code:
// MI.cpp : Defines the exported functions for the DLL application.
#include <windows.h>
#include "stdafx.h"
#include "Commctrl.h"
#include "resource.h"

//Main Window
BOOL CALLBACK MIDialog(HWND hMI, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
   switch(uMsg)
   {

      case WM_INITDIALOG:   
         TCITEM Tab;
         Tab.mask  = TCIF_TEXT;
         Tab.iImage = -1;
         Tab.pszText = (LPTSTR)"Tab1";
         SendDlgItemMessage(hMI,IDC_TAB,TCM_INSERTITEM,0,(LPARAM)&Tab);
         Tab.pszText = (LPTSTR)"Tab2";
         SendDlgItemMessage(hMI,IDC_TAB,TCM_INSERTITEM,1,(LPARAM)&Tab);
         Tab.pszText = (LPTSTR)"Tab3";
         SendDlgItemMessage(hMI,IDC_TAB,TCM_INSERTITEM,2,(LPARAM)&Tab);
         Tab.pszText = (LPTSTR)"Tab4";
         SendDlgItemMessage(hMI,IDC_TAB,TCM_INSERTITEM,3,(LPARAM)&Tab);
      break;

      case WM_HOTKEY:
      break;

      case WM_COMMAND:
         switch(LOWORD(wParam))
         {
         }
      break;

      case WM_NOTIFY: // Notify us when ...
         switch (((LPNMHDR)lParam)->code)
         {
            case TCN_SELCHANGE: // selected tab is changed
               int tabSel = SendDlgItemMessage(hMI,IDC_TAB,TCM_GETCURSEL,0,0);;
               if ( tabSel == 0 ){
               }
               if ( tabSel == 1 ){
               }
               if ( tabSel == 2 ){
               }
               if ( tabSel == 3 ){
               }
            break;
         }
      break;

      case WM_CLOSE: // PRESS X close
         EndDialog(hMI, 0);
      break;

      default:
         return FALSE;
   }
   return true;
}


//Show Dialogue
unsigned long WINAPI MainWin( HMODULE hModule){
   Sleep(100);
   DialogBox(hModule, MAKEINTRESOURCE(IDD_MAIN), NULL, (DLGPROC)MIDialog);
   FreeLibraryAndExitThread(hModule,0);
   return 0;
}

BOOL APIENTRY DllMain( HMODULE hModule,
                       unsigned long  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;
}


so, i have to create my remaining 3 dialogs in my MainWin thread with DialogBox(...)?
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Wed Apr 28, 2010 6:34 am    Post subject: Reply with quote

no, you use CreateDialog or one of its variants :
http://msdn.microsoft.com/en-us/library/ms645434(VS.85).aspx

because it returns straight after creation unlike DialogBox which only returns after EndDialog. so you create all your tab contents as modeless dialogues. then show/hide them when a tab changes
Back to top
View user's profile Send private message
zile
Advanced Cheater
Reputation: 0

Joined: 11 Jul 2009
Posts: 75

PostPosted: Wed Apr 28, 2010 8:13 am    Post subject: Reply with quote

ok got it, ill test it out and see

edit : ive done with setwindowpos and all,
but now, when i use showwindow to hide and show another tab, the taskbar removes my window and places the new window, this is very annoying because it happens everytime i change tab

is there any way to fix this?
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Wed Apr 28, 2010 1:24 pm    Post subject: Reply with quote

i'm not 100% sure what you mean. when you create the dialogs that are inside the main one ( ie. the tab contents ), they should be created as children of the main dialog holding the tab control itself.

could you show your code ?
Back to top
View user's profile Send private message
zile
Advanced Cheater
Reputation: 0

Joined: 11 Jul 2009
Posts: 75

PostPosted: Wed Apr 28, 2010 4:55 pm    Post subject: Reply with quote

Slugsnack wrote:
i'm not 100% sure what you mean. when you create the dialogs that are inside the main one ( ie. the tab contents ), they should be created as children of the main dialog holding the tab control itself.

could you show your code ?


no wonder lol, i made all of them in MainWin thread, ill try it out when i get back
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Wed Apr 28, 2010 5:40 pm    Post subject: Reply with quote

make them in the wm_initdialog of the dialog holding the tab control and have them all as initially hidden except the one that should be shown on the first tab. then you just handle the message TCL_SELCHANGE to hide/unhide children dialogs
Back to top
View user's profile Send private message
zile
Advanced Cheater
Reputation: 0

Joined: 11 Jul 2009
Posts: 75

PostPosted: Thu Apr 29, 2010 1:03 am    Post subject: Reply with quote

new code

Code:
// MI.cpp : Defines the exported functions for the DLL application.
#include <windows.h>
#include "stdafx.h"
#include "Commctrl.h"
#include "resource.h"

HINSTANCE SaveModuleHandle = NULL;
HWND hMain = NULL;
HWND hTab2 = NULL;
HWND hTab3 = NULL;
HWND hTab4 = NULL;

RECT tabRect;
TCITEM Tab;

BOOL CALLBACK MITab4(HWND hMITab4, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
   switch(uMsg)
   {

      case WM_INITDIALOG:   
         Tab.mask  = TCIF_TEXT;
         Tab.iImage = -1;
         Tab.pszText = (LPTSTR)" Tab1";
         SendDlgItemMessage(hMITab4,IDC_TAB,TCM_INSERTITEM,0,(LPARAM)&Tab);
         Tab.pszText = (LPTSTR)"Tab2";
         SendDlgItemMessage(hMITab4,IDC_TAB,TCM_INSERTITEM,1,(LPARAM)&Tab);
         Tab.pszText = (LPTSTR)"Tab3";
         SendDlgItemMessage(hMITab4,IDC_TAB,TCM_INSERTITEM,2,(LPARAM)&Tab);
         Tab.pszText = (LPTSTR)"Tab4";
         SendDlgItemMessage(hMITab4,IDC_TAB,TCM_INSERTITEM,3,(LPARAM)&Tab);
      break;

      case WM_HOTKEY:
      break;

      case WM_COMMAND:
         switch(LOWORD(wParam))
         {
         }
      break;

      case WM_NOTIFY: // Notify us when ...
         switch (((LPNMHDR)lParam)->code)
         {
            case TCN_SELCHANGE: // selected tab is changed
               int tabSel = SendDlgItemMessage(hMITab4,IDC_TAB,TCM_GETCURSEL,0,0);
               GetWindowRect(hMITab4,&tabRect); // Get position
               if ( tabSel == 0 ){ // Selected Scanner Tab
                  ShowWindow(hMain,SW_SHOW);
                  SetWindowPos(hMain,HWND_TOP, tabRect.left, tabRect.top, 0, 0, SWP_NOSIZE); // Set position
                  ShowWindow(hTab4,SW_HIDE);
                  SendDlgItemMessage(hMain,IDC_TAB,TCM_SETCURSEL,0,0);
               }
               if ( tabSel == 1 ){ // Selected Tab2 Tab
                  ShowWindow(hTab2,SW_SHOW);
                  SetWindowPos(hTab2,HWND_TOP, tabRect.left, tabRect.top, 0, 0, SWP_NOSIZE); // Set position
                  ShowWindow(hTab4,SW_HIDE);
                  SendDlgItemMessage(hTab2,IDC_TAB,TCM_SETCURSEL,1,0);
               }
               if ( tabSel == 2 ){ // Selected Tab3 Tab
                  ShowWindow(hTab3,SW_SHOW);
                  SetWindowPos(hTab3,HWND_TOP, tabRect.left, tabRect.top, 0, 0, SWP_NOSIZE); // Set position
                  ShowWindow(hTab4,SW_HIDE);
                  SendDlgItemMessage(hTab3,IDC_TAB,TCM_SETCURSEL,2,0);
               }
            break;
         }
      break;

      case WM_CLOSE: // PRESS X close
         EndDialog(hMain,0);
      break;

      default:
         return FALSE;
   }
   return true;
}

//Main Window
BOOL CALLBACK MIDialog(HWND hMIDialog, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
   switch(uMsg)
   {

      case WM_INITDIALOG:   
         hTab2 = CreateDialog(SaveModuleHandle, MAKEINTRESOURCE(IDD_Tab2), NULL, (DLGPROC)MITab2); // Create Tab2 tab
         hTab3 = CreateDialog(SaveModuleHandle, MAKEINTRESOURCE(IDD_Tab3), NULL, (DLGPROC)MITab3); // Create Tab3 tab
         hTab4 = CreateDialog(SaveModuleHandle, MAKEINTRESOURCE(IDD_Tab4), NULL, (DLGPROC)MITab4); // Create Tab4 tab

         Tab.mask  = TCIF_TEXT;
         Tab.iImage = -1;
         Tab.pszText = (LPTSTR)" Tab1";
         SendDlgItemMessage(hMIDialog,IDC_TAB,TCM_INSERTITEM,0,(LPARAM)&Tab);
         Tab.pszText = (LPTSTR)"Tab2s";
         SendDlgItemMessage(hMIDialog,IDC_TAB,TCM_INSERTITEM,1,(LPARAM)&Tab);
         Tab.pszText = (LPTSTR)"Tab3";
         SendDlgItemMessage(hMIDialog,IDC_TAB,TCM_INSERTITEM,2,(LPARAM)&Tab);
         Tab.pszText = (LPTSTR)"Tab4";
         SendDlgItemMessage(hMIDialog,IDC_TAB,TCM_INSERTITEM,3,(LPARAM)&Tab);
         hMain = hMIDialog;
      break;

      case WM_HOTKEY:
      break;

      case WM_COMMAND:
         switch(LOWORD(wParam))
         {
         }
      break;

      case WM_NOTIFY: // Notify us when ...
         switch (((LPNMHDR)lParam)->code)
         {
            case TCN_SELCHANGE: // selected tab is changed
               int tabSel = SendDlgItemMessage(hMIDialog,IDC_TAB,TCM_GETCURSEL,0,0);
               GetWindowRect(hMIDialog,&tabRect); // Get position
               if ( tabSel == 1 ){ // Selected Tab2s Tab
                  ShowWindow(hTab2,SW_SHOW); // Show Tab2s tab
                  SetWindowPos(hTab2,HWND_TOP, tabRect.left, tabRect.top, 0, 0, SWP_NOSIZE); // Set position
                  ShowWindow(hMain,SW_HIDE); // Hide Scan Tab
                  SendDlgItemMessage(hTab2,IDC_TAB,TCM_SETCURSEL,1,0); // Set currently selecting Tab2s Tab
               }
               if ( tabSel == 2 ){ // Selected Tab3 Tab
                  ShowWindow(hTab3,SW_SHOW);
                  SetWindowPos(hTab3,HWND_TOP, tabRect.left, tabRect.top, 0, 0, SWP_NOSIZE); // Set position
                  ShowWindow(hMain,SW_HIDE);
                  SendDlgItemMessage(hTab3,IDC_TAB,TCM_SETCURSEL,2,0);
               }
               if ( tabSel == 3 ){ // Selected Tab4 Tab
                  ShowWindow(hTab4,SW_SHOW);
                  SetWindowPos(hTab4,HWND_TOP, tabRect.left, tabRect.top, 0, 0, SWP_NOSIZE); // Set position
                  ShowWindow(hMain,SW_HIDE);
                  SendDlgItemMessage(hTab4,IDC_TAB,TCM_SETCURSEL,3,0);
               }
            break;
         }
      break;

      case WM_CLOSE: // PRESS X close
         EndDialog(hMain,0);
      break;

      default:
         return FALSE;
   }
   return true;

//Show Dialogue
unsigned long WINAPI MainWin( HMODULE hModule){
   Sleep(100);
   SaveModuleHandle = hModule;
   DialogBox(hModule, MAKEINTRESOURCE(IDD_MAIN), NULL, (DLGPROC)MIDialog);
   FreeLibraryAndExitThread(hModule,0);
   return 0;
}

BOOL APIENTRY DllMain( HMODULE hModule,
                       unsigned long  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;
}


i've only shown tab4, cuz its the same as 2 and 3

and it still has the problem, its like when i select another tab, the taskbar below shows my app disappearing and appearing, kinda like what happens when you close a prog and running it again

when i use SetParent and select another tab, nothing comes out.
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Thu Apr 29, 2010 5:56 am    Post subject: Reply with quote

in the createdialog calls, 3rd parameter, set those dialogs as children to the main one there. in your case hMIDialog. also if you do it right, there should be no need for any setwindowpos calls since it is possible to specify coordinate offsets in your resource file
Back to top
View user's profile Send private message
zile
Advanced Cheater
Reputation: 0

Joined: 11 Jul 2009
Posts: 75

PostPosted: Thu Apr 29, 2010 6:05 am    Post subject: Reply with quote

Slugsnack wrote:
in the createdialog calls, 3rd parameter, set those dialogs as children to the main one there. in your case hMIDialog. also if you do it right, there should be no need for any setwindowpos calls since it is possible to specify coordinate offsets in your resource file


now , when i select tab 2/3/4 , the window in taskbar disappears and will only appear when i select tab 1 (parent - hMIDialog)

it should be due to hiding the parent window...
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Thu Apr 29, 2010 6:18 am    Post subject: Reply with quote

why are you even hiding the parent window ? you're not supposed to do that. the only things you should be hiding and showing are the children dialogs inside the tab control. in your case htab2, htab3, htab4
Back to top
View user's profile Send private message
zile
Advanced Cheater
Reputation: 0

Joined: 11 Jul 2009
Posts: 75

PostPosted: Thu Apr 29, 2010 6:28 am    Post subject: Reply with quote

but my parent is also one of the tabs, if i dont hide it, wouldnt there be 2 dialogs shown when i select another tab? eg. when i select tab2, hMIDialog and hTab2 is shown

maybe i coded it wrong, pls check my code above...?
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
Goto page 1, 2  Next
Page 1 of 2

 
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