I have made an ATL control (ActiveX) and I can display it easily in MFC CDialog. Now I need to display it in CView of MFC single document project by using the code (just like the picture below).
Don't use CForm because my customer don't need it. They need exactly Control display in CView by code.
Are there any tutorial or suggestion for this task?
The MFC CView class doesn't directly support hosting of Win32 or ActiveX controls on its surface. That functionality is built into the CFormView class. If you want to readily host controls on your view, you should be using CFormView.
Related
I am developing a MFC dialog based windows application in VS2019 C++. Is there any library available for the UI design, such as adding background images, colors, font styles, buttons etc?
If anyone has any suggestions regarding the UI design of MFC C++ dialog applications, please tell me. I want to have a modern style UI and it is also not possible to change the framework.
Ok, so my intention is to "prettify" a UI I'm working on. I'm familiar with using GDI+ to manually draw my controls but my target today is simply BitBlitting png's on my DC directly.
That works nice and fine with the main frame, a few buttons and perhaps some menus.
My question is - how would you skin something more complicated like a combobox, listview or more "dynamic" controls using such skins?
Thank you. My target platform is Windows and I'm using C++ with the wxWidgets framework.
To 'skin' an existing control you'll have to subclass the window and catch the draw messages.
roughly:
// Subclass the control
WNDPROC lpfnOldCtrlProc;
lpfnOldCtrlProc = (WNDPROC)SetWindowLong(ControlHwnd, GWL_WNDPROC,
(DWORD)WinSubClassFunc );
and in your WinSubClassFunc:
switch( message )
{
case WM_DRAWITEM: // owner-draw the item
However, if you want to fully 'skin' a control e.g. change all elements of a ComboBox (border, entrybox, dropdown button, droplist etc.) then this becomes really messy.
Personally, I find it is easier to create your own control from scratch than try to subclass an existing control which consists of multiple window items.
The above methods works fine for e.g. using a standard combobox with a droplist and subclass it to make it contain a droplist of colour bars.
I have a dialog based MFC application. Now I want to create a wiew (one or more) with a toolbar, scroll bars and a client window (based on CWnd).
What MFC class should I base this window on?
What is the best way to do it?
Thanks.
Using a scrolling client window is more natural in a Document-View application than a dialog based application -- you can have menu bars and toolbars connected to a dialog, but to a View as far as I know.
A SDI application allows support for multiple docking/floating toolbars and multiple views of the same document, so this would be my advice...
Start with a CFrameWnd. It's job is to give your window a titlebar/close button etc., and position control bars (such as a toolbar) and a menu (if you want one) and a view within itself. The view should be a CScrollView (for painted graphics) or a CFormView (for dialog-like controls).
You will find this to be a lot easier if your just start from scratch and let the app wizard generate an SDI or MDI app to start with.
I want to design a student registration and exam recording app using C++ MFC with a kind of child window containing buttons edits and other common controls which is displayed on the app client area, and can be removed and replaced with another one by clicking a button. Thats the problem i face now( The GUI ). I came from JAVA background where this can be done by creating a JPanel as a container for the buttons, combo boxes and text fields controls. the panel is displayed on the client area and can be removed and replaced with another panel containing a new set of controls. I tried learning CView but it keeps talking about documents and views that displays untitled document as in word processing. Any pointer will be appreciated. Thanks.
After having searched and read a lot about my problem, i decided to go into win32 API where everything is possible depending on your awareness.The solution is as simple as creating a main window and creating any number of child windows who uses the main window as parent and all has a hiden window attribute. Then you can create controls on each child window. To switch between the child windows I did this: ShowWindow(childWindow1, SW_HIDE); ShowWindow(childWindow2, SW_SHOW);. thats it, only that the repaint process after restore does not repaint the child window's controls and its child window.
Is there something like a panel that I can use in a MFC application. This is to overlay the default window in MFC (a dialog application). Then to paint the panel black and paint some random stuff on top of it. Something like a view port.
is there a better option than this to achieve the same effect ?
Sure. It's called a window! Create a class that derives from CWnd and overrides OnPaint().
In your dialog's OnInitInstance(), instantiate a CMyWnd object and call it's Create() member. Of course, make sure the lifetime of your CMyWnd object is the same as the dialog's object lifetime window. iow, make it a member of you CMyDialog class.
Not very complicated but obviously an area where MFC shows why it doesn't fall in the RAD tools category.
Another solution would be to derive from CDialog. This way you can use the resource editor to edit the panel visually and you don't need to paint anything yourselve. Also the Panel class is rather thin and just needs to propagate the Create() and Show() calls to support subpanels and multiple panels within a single form.