I see that you can enable/disable using the EnableWindow method, but how do I get it's current state?
Use IsWindowEnabled.
Related
In WinAPI you can call global function SetFocus(HWND) to set focus to NULL window (keystrokes are ignored):
::SetFocus(NULL);
wxWidgets have wxWindow::SetFocus(void) virtual member function so you cannot pass NULL. How to do portable equivalent of ::SetFocus(NULL) in wxWidgets?
There is no way to do it in wxWidgets API (but then it's not clear why would anybody want to do it).
You can ignore all keys by checking for the corresponding events in wxApp::FilterEvent() if you need to do it globally.
I am developing an MFC application, can i use SHAutoComplete with a CEdit control? Also is there any ready made auto complete controls are available? or i need to use write all the code for creating the list box below the edit control as user types in edit control?
Just pass CEdit's m_hwnd member to SHAutoComplete. I don't think that extension warrant another class. The listbox is created by the AutoComplete object created by SHAutoComplete.
SHAutoComplete helps to autocomplete paths (system or URL).
If this is a combo box and you want to use autocomplete for suggesting string contained in the combo, you have to write a code to handle it.
There are samples you can find. One I found (working):
http://www.ucancode.net/Visual_C_MFC_COM_faq/Visual-C-Auto-completion-ComboBox-CComboBox.htm
I have a CMFCToolBarComboBoxButton on a CMFCToolBar. I want that whenever the CMFCToolBarComboBoxButton gets the focus its entire text will be selected.
What is the most elegant way to implement it?
Thanks a lot!
Adi Barda
Not sure what the most elegant way is, but I guess the most common way to do this is to make a derived class and override OnSetFocus (exact method name not checked), and call SetCurSel() on the contained edit control. WM_FOCUS is only send to the control and there is no notification message for it afaik, so you'll have not many options besides doing something that will make the control handle the event - be it reflect it to somewhere else, or just implement the behavior itself. (I guess theoretically there's all sorts of finicking one can do with intercepting messages, but that's certainly not the most elegant way...)
That should be the default behavior of the standard edit control. If it's not, something else is removing that behavior explicitly. Maybe you can find some flag you can set on the combobox button?
If not: subclass the edit control, handle the WM_GETDLGCODE message. Return a value ORed with DLGC_HASSETSEL. If the control has this flag set, then Windows will automatically select all text on focus.
What is the proper way to subclass a tab control in winAPI, having windows perform both the default drawing and your own. Because BeginPaint() and EndPaint() are calling within the default proc, I don't see a way to do this. I did get it working with GetDC(), but it had a very bugs which annoyed the hell out of me.
If what I am asking is impossible, what is the best way to draw the tabs by myself?
Subclassing is not required in your situation. The tab control supports the TCS_OWNERDRAWFIXED style bit, which allows its parent window to handle WM_DRAWITEM messages and draw the tabs itself.
There's a nice exemple on Codeguru. It uses MFC but don't let that stop you. Check out their CTabCtrlEx::DrawItem() method.
I have the following unmanaged C++ code:
MessageBox( NULL, strMessage, "Cool Product", MB_RETRYCANCEL | MB_ICONEXCLAMATION);
I want to disable the RETRY button for 10 seconds (for example), then enable it.
How can I do this?
Like #ffpf says, you need to make your own dialog to do this, using MFC, ATL, raw Win32, etc.
Then create a timer that would enable and disable the button.
You cannot directly manipulate the MessageBox controls, but you can use a hack. Install a WH_CBT hook just before displaying the dialog and handle the HCBT_ACTIVATE event. This will give you the HWND of the message box, so that you can do whatever you want with it (subclass it, manage its buttons and set a timer).
You can find a Custom MessageBox tutorial with demo code in James Brown's site.
With the standard MessageBox call, you can't. You'd need to implement your own MessageBox in order to do this.
I don't believe this is possible with the standard message box call.
You would probably be better off writing your own message box that includes this functionality.
(Or, you could write a separate thread that continually watches the screen waiting for that message box to appear, disable the retry button, wait 10 seconds and reenable it. Not fun. Seriously, do it the other way.)
Since Vista you can use taskdialog -- a more sophisticated dialog than a simple message box. More info and links here.
I agree with efotinis, it's not impossible, once you have the HWND you can do whatever you want with it. It is just a matter of "do you really need the hacks or are you better off with just creating your own message box dialog"?
Another not so nice way of finding the HWND (which would obviously give you access to eveything in the message box) would be to start a thread and ciclically poll for the message box handle by using EnumChildWindows. But I personally would prefer the WH_CBT hook also.