Win32Api - Window Name Property - c++

Is there any way to get a control's name through win32api? (c++)
I'm talking about the property that in C# is 'Name', like 'frmMain', or 'btnNext'.
Is there any way to retrieve this data through the win32API?
I've tried GetWindowInfo() and stuff but I think I'm not heading in the right direction..
thanks
edit: I'm iterating with EnumChildWindows() and I got the correct HWND.. not sure if I can use it to print it's name.. (im a c++/win32 absolute noob)
Added 7/10/09
By the way I found this really good tool to operate win32 apps.
http://www.autoitscript.com/autoit3/
Check it out looks good and looks like it's freeware? :)

The name of a control is usually a private variable of the control and is not exposed to win32. You could try GetWindowText to get the title of some controls or GetWindowLong to get some properties, but I don't think you can get the name of most controls.

I seriously doubt that this information is even in the executable code, I would think that from the c# compilers point of view these symbols get reduced to object pointers or window identifiers values (the IDC_ mentioned above).
Having been faced with this type of problem before I chose to create hidden static text controls with identifying text on each window to provide this named window capability to an external process. Not very elegant but solved my problem at the time.

The name property is something added, AFAIK, by the compiler. Win32 does not, inttrinsicaly, support naming like this.
In C/C++ one uses the IDC_* value instead with the added bonus that integer comparisons are far faster than string comparison.
Edit: Btw Its possible to use the IDC values mentioned above to get child controls of a dialog by using the GetDlgItemInt( hDlgWnd, IDC_* ) to get an HWND to the control. Far easier then using EnumWindows ....

Related

How to set font in edit box part of a CMFCToolBarComboBoxButton?

I'm able to set the font used to draw the drop-down part of a CMFCToolBarComboBoxButton combo box which is embedded in a CMFCToolBar toolbar. However, I'm not able to set/change the font used for the edit field control which is part of the combo box. I.e., when the combo box is collapsed the currently selected item is always drawn with the standard/default font no matter what font is used for the entries when expanding the box.
I successfully change the font of the drop down box part by using a pointer to the underlying CComboBox object retrieved via CMFCToolBarComboBoxButton::GetComboBox() (and then via CComboBox::SetFont(...)). But when using the method CMFCToolBarComboBoxButton::GetEditCtrl() to obtain a pointer to the edit control part (in order to change its font, too) this method always returns a nulltpr. Does anybody know why or more importantly: What is the correct way to set the font used for the edit control part of the box?
I've searched the web now quite a lot but cannot find a solution to the problem. Thanks for any advice!
Additional note: I need to change the used font(s) at run time in my MFC application.
OK, I finally came to the conclusion that it's better to leave these fonts up to the OS settings anyway and not explicitly set them by the application code.
This is not a technically correct answer to the (my own) question, certainly, but may be a good advide for others chasing the same problem.

Static wxRichTextControl?

I want to create an Help page for my wxWidgets application, which consists of only text of various fonts, sizes and colors. I tried achieving that with wxStaticText's and sizers but I was having trouble so I switched to a wxRichTextCtrl, which I like to use. The problem is, the text should of course be non-modifiable. I know of the existance of the wxRE_READONLY flag, but it doesn't hide the caret that appears when I click on the text.
Isn't there some kind of wxRichStaticTextCtrl that works exactly like a wxRichTextCtrl, but is readonly by default and doesn't have this problem? I tried looking online, but to no avail.
The best solution for "rich" static text is wxHtmlWindow: this allows you to just define your help contents in terms of simple HTML which is usually more than enough.

How to use images in GTK Stack Switcher

I'm writing an application using C++ and gtkmm. I made a Gtk stack in it. Now I want to add images instead of text on stackswitcher's buttons. I assume that it's possible because something like this is made in gtk3-demo:
Unfortunatelly the example is made using UI file and I want to do it without UI designer. For now I found this answer:
But it's not very helpful to me. The answer was to use stack.child_set_property but I checked gtkmm documentation for stack and there isn't anything like this for C++. The closest match was Gtk::Stack::child_property_name with adnotation that it returns A ChildPropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes. I suppose this may be the thing i'm looking for, but due to lack of examples I have no idea how to use it.
To sum up: Is anyone able to tell me how to set an image as StackSwitcher's label?
Ok, it seems I've found an answer. I'll post it if anyone needs it in the future:
To change Stack Switcher's text label into image I just needed to do that:
stack->child_property_icon_name(ChildName) = "Icon Name";

Get system icon

A simple question.
How do I get these system icons?
I use this interface:
https://msdn.microsoft.com/en-us/library/ms676973(v=vs.85).aspx
SHGetStockIconInfo function uses enum SHSTOCKICONID where there are these icons.
Can you tell me please id these icons?
Have you tried SIID_USERS? That would appear to be the one you want.

How to implement Outlook Express alike address field control

I was thinking about inserting some object (button, panel or static text) into textctrl, like Outlook Express does this.
You can see from a pic "group1" is an object, you can double click on it, when you delete it, it gets deleted the whole text not just a part of it.
I made some research and this text field is just a simple RichEdit20W. I understand that I can do it by implementing some logic to a text field and so on, but it will not be proper way of doing it.
I wonder how they done that. Should I implement IRichEditOleCallback interface to achieve that? I will appreciate your answer very much.
Thanks!
The ability to insert an object is built-in to the RichEdit control, that's what Outlook is using, and you can do the same yourself. It seems you would need to implement your own OLE object for your own item, and then use the RichEdit's COM interface to insert it. You can see a sample on MSDN that gets the COM interface and inserts an object here.