Sigma Posted September 18, 2006 Posted September 18, 2006 Does anyone know how to achieve VEOVEO like behavior? I ideal would like to check to see if a certain window is running, then if that window has focus, and if so, enable the buttons.In a pseudo-code/C hybrid:if((Window_Caption == "My window") && ("My Window" has focus){Enables buttons}I have no idea what to even look for API wise in MSDN, so I'd take any hints/suggestions/pointers.Thanks
Killboy Posted September 18, 2006 Posted September 18, 2006 I've seen a patch for TMPGenc XPress. The problem was, you had to reenable some kinda license. However, the boxes for the 'serial' used to retrieve a trial lic by some server couldnt be changed. This tool was meant to do exactly this, making them writable... The most ridiculous about it was, that it crashed when you pulled the app above TMPGenc and hit 'Enable editboxes' LOL Actually, I can't help you w/ your problem, sorry // Searching MSDN for 'enable label' 'enable menu' did not help ?
Sigma Posted September 18, 2006 Author Posted September 18, 2006 (edited) //EDITThanks yamraaj, i got it.What is the best way (give you know the HWND of the window in question) to find a specific button? Edited September 18, 2006 by Sigma
revert Posted September 19, 2006 Posted September 19, 2006 I have done this once using the FindWindow and the EnumChildProc API.void CLauncherDlg::OnBnClickedOk(){ CWnd* handle1 = NULL; handle1 = FindWindow(NULL, "Some window"); if(handle1) { EnumChildWindows(handle1->m_hWnd, EnumChildProc, 0); }}BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam){ char szBuffer[100]; int iResult = GetWindowText( hwnd, szBuffer, 100); CString sTest = szBuffer; if(sTest == "caption from button") { // Your code here }}Hope it helps.Good luck.
revert Posted September 19, 2006 Posted September 19, 2006 Sh**t, I just noticed you are asking about a Menu Button. The snipet I posted was to find the handle to a regular button, I'm not sure if it will help.
Sigma Posted September 20, 2006 Author Posted September 20, 2006 Hey man, thanks for the code. I actually sorted it out same method tho! I couldn't get the menu button to work, so i'm just enabling the button. Ah well! Cheers all
proletsearch Posted January 8, 2008 Posted January 8, 2008 This thread is quite old, but I will post a quite old but working asm solution. It might help someone else It's not mine solution. Author notes below: ; Author: Deuce ; Enables all child windows belonging to the foreground window. .386.model flat,stdcallinclude \masm32\include\windows.incinclude \masm32\include\kernel32.incinclude \masm32\include\user32.incincludelib \masm32\lib\kernel32.libincludelib \masm32\lib\user32.libDlgProc proto :DWORD,:DWORD,:DWORD,:DWORDEnableAll proto :DWORD, :DWORD.constENABLER equ 101ICON equ 102IDC_HANDLE equ 1002IDC_ENABLE equ 1001TIMERID equ WM_USER.datatemplate db '%lX',0posBuffer db 10 dup (0).codestart: invoke GetModuleHandle,NULL invoke DialogBoxParam,eax,ENABLER,NULL,offset DlgProc,NULL invoke ExitProcess,eaxDlgProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM cmp uMsg,WM_TIMER ;It's been 200 ms, enumerate the windows again! je getPoint cmp uMsg,WM_INITDIALOG ;Initialization stuff je boxStart cmp uMsg,WM_CLOSE je boxClose retFalse: mov eax,FALSE ret boxStart: invoke SetTimer,hWnd,TIMERID,200,NULL ;Start up the timer for 200 ms intervals jmp retTrue boxClose: invoke KillTimer,hWnd,TIMERID ;Okay we're done so shut everything down invoke EndDialog,hWnd,NULL jmp retTrue getPoint: invoke IsDlgButtonChecked,hWnd,IDC_ENABLE ;Are we activated? cmp eax,BST_CHECKED jne retTrue invoke GetForegroundWindow ;Yep, what window is activated? push eax invoke wsprintf,offset posBuffer,offset template,eax ;Translate handle value to ASCII invoke SetDlgItemText,hWnd,IDC_HANDLE,offset posBuffer;Set the handle edit box pop eax invoke EnumChildWindows,eax,offset EnableAll,NULL ;Now we are gonna filter through all child windows retTrue: mov eax,TRUE retDlgProc endpEnableAll proc hWnd:HWND,lParam:LPARAM ;Windows sends the handle of each child window here invoke IsWindowEnabled,hWnd ;Is this child window enabled or not? cmp eax,TRUE je getNext invoke EnableWindow,hWnd,TRUE ;No, it's not! So we'll enable it :) getNext: mov eax,TRUE ;Return TRUE to get handle of next child window retEnableAll endpend start
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now