• Welcome to PlanetSquires Forums.
 

WinFBE using CWindow #3

Started by Paul Squires, June 01, 2016, 07:23:48 PM

Previous topic - Next topic

Paul Squires

Hi Jose,

I am taking my first shot at adding the "Environment Options" dialog. I think I am having trouble with the child forms and the controls not having the font set. When I run the program, the controls show with the default system font. Any idea why?
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

I will check, step by step.

In the first place, I have needed to add a couple of CASTs.

Also, the program remained in memory, so I have added PostQuitMessage.


' ========================================================================================
' Process WM_DESTROY message for window/dialog: frmOptions
' ========================================================================================
Function frmOptions_OnDestroy(HWnd As HWnd) As LRESULT
   PostQuitMessage(0)
   Function = 0
End Function


Paul Squires

Oh, yes, I forgot that PostQuitMessage in order to get out of the message loop for the modal window. I have now added it. I will have a lot of time tomorrow to work on these forms so hopefully after tomorrow much of the environment options will be workable.

I don't think that you ported all of your control wrappers to FB, right? I used a couple of my FireFly Functions for things like the Treeview.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

...I fixed those missing CAST's and missing Function values.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

Don't know yet what its happening. If I made the options dialog a popup window, add a message pump and process the messages, and disable the parent, the controls are created as it should.


Paul Squires

Yes, the main FRMOPTIONS window is setting the fonts okay as well. It only happens when I am using the embedded child forms FRMOPTIONSEDITOR, FRMOPTIONSCOLORs, FRMOPTIONSCOMPILER. Must have something to do with the message pump. I will test tomorrow as well.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

Hi Jose,

Maybe you can add a property to the CWindow class to be able to retrieve the default font face name (m_wszDefaultFontName)? Some of my controls need to be set at different sizes. I am using the class's CreateFont method but I must pass the name of the font. Depending on the version of operating system, I would want to use a different default font name. You already do this for the class when the main window is created so rather than me having to do a AfxWindowsVersion and store the font name, it would be more convenient to get it via the CWindow class.

...or...

Modify the CreateFont method so that if I pass a null string for the font name to the CreateFont method it will use the default font?

   Dim As HFONT hFont = pWindow.CreateFont("", 14, FW_BOLD)

What do you think?
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

Hi Jose, I updated the first post to include a new attachment with all of the changes mentioned in this thread so far. It also has code for handling different color for the "Category Label". Basically a foreground blue color on a standard button face color background.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

#8
The most strange is that you're doing more or less what I do with the tab pages of a tab control, and they work fine. Also if I pass the font handle of the main window to the options form and set this font, the font that changes is the one of the main form, that becomes smaller!

José Roca

> What do you think?

I will do.

José Roca

I don't understand what is happening with the fonts. How can it be that trying to change the font of the frmOptionsEditor what changes is the font of frmOptions?

José Roca

I have added the DefaultName property and also changed SetFont and CreateFont to allow to pass an empty string for the font name.

José Roca

Don't know if there is a bug in the compiler or what, but if I change in frmOptions.inc


   '  Create the main window and child controls
'   frmOptionsEditor_Show( pWindow.hWindow )
   Dim pWinOpEd As CWindow
   HWND_FRMOPTIONSEDITOR = pWinOpEd.Create( pWindow.hWindow, "", @frmOptionsEditor_WndProc, 0, 0, 354, 319, _
        WS_CHILD Or WS_CLIPSIBLINGS Or WS_CLIPCHILDREN, _
        WS_EX_CONTROLPARENT Or WS_EX_LEFT Or WS_EX_LTRREADING Or WS_EX_RIGHTSCROLLBAR)
   pWinOpEd.SetClientSize(354, 319)
   frmOptionsEditor_Show(@pWinOpEd)


and in frmOptionsEditor_Show


' ========================================================================================
' frmOptionsEditor_Show
' ========================================================================================
'Function frmOptionsEditor_Show( ByVal hWndParent As HWnd, _
'                                ByVal nCmdShow   As Long = 0 _
'                                ) As Long

Function frmOptionsEditor_Show( ByVal pWindow AS CWindow PTR) As Long

   pWindow->AddControl("LABEL", pWindow->hWindow, IDC_FRMOPTIONSEDITOR_LBLTABSIZE, "Tab Size:", 38, 273, 86, 17, _
        WS_CHILD Or WS_VISIBLE Or WS_CLIPSIBLINGS Or WS_CLIPCHILDREN Or SS_LEFT Or SS_NOTIFY, _
        WS_EX_LEFT Or WS_EX_LTRREADING)
   pWindow->AddControl("TEXTBOX", pWindow->hWindow, IDC_FRMOPTIONSEDITOR_TXTTABSIZE, "", 2, 270, 30, 20, _
        WS_CHILD Or WS_VISIBLE Or WS_TABSTOP Or ES_LEFT Or ES_AUTOHSCROLL Or ES_NUMBER, _
        WS_EX_CLIENTEDGE Or WS_EX_LEFT Or WS_EX_LTRREADING Or WS_EX_RIGHTSCROLLBAR)
   pWindow->AddControl("LABEL", pWindow->hWindow, IDC_FRMOPTIONSEDITOR_LBLKEYWORDCASE, "Case:", 167, 273, 34, 16, _
        WS_CHILD Or WS_VISIBLE Or WS_CLIPSIBLINGS Or WS_CLIPCHILDREN Or SS_LEFT Or SS_NOTIFY, _
        WS_EX_LEFT Or WS_EX_LTRREADING)
   pWindow->AddControl("COMBOBOX", pWindow->hWindow, IDC_FRMOPTIONSEDITOR_COMBOCASE, "", 208, 269, 125, 22, _
        WS_CHILD Or WS_VISIBLE Or WS_VSCROLL Or WS_TABSTOP Or CBS_DROPDOWNLIST, _
        WS_EX_CLIENTEDGE Or WS_EX_LEFT Or WS_EX_LTRREADING Or WS_EX_RIGHTSCROLLBAR)
   pWindow->AddControl("CHECKBOX", pWindow->hWindow, IDC_FRMOPTIONSEDITOR_CHKCODETIPS, "Enable CodeTips", 0, 21, 179, 20, _
        WS_CHILD Or WS_VISIBLE Or WS_TABSTOP Or BS_TEXT Or BS_NOTIFY Or BS_AUTOCHECKBOX Or BS_LEFT Or BS_VCENTER, _
        WS_EX_LEFT Or WS_EX_LTRREADING)
   pWindow->AddControl("CHECKBOX", pWindow->hWindow, IDC_FRMOPTIONSEDITOR_CHKSHOWLEFTMARGIN, "Show left margin", 185, 0, 179, 20, _
        WS_CHILD Or WS_VISIBLE Or WS_TABSTOP Or BS_TEXT Or BS_NOTIFY Or BS_AUTOCHECKBOX Or BS_LEFT Or BS_VCENTER, _
        WS_EX_LEFT Or WS_EX_LTRREADING)
   pWindow->AddControl("CHECKBOX", pWindow->hWindow, IDC_FRMOPTIONSEDITOR_CHKSYNTAXHIGHLIGHTING, "Syntax highlighting", 0, 0, 179, 20, _
        WS_CHILD Or WS_VISIBLE Or WS_TABSTOP Or BS_TEXT Or BS_NOTIFY Or BS_AUTOCHECKBOX Or BS_LEFT Or BS_VCENTER, _
        WS_EX_LEFT Or WS_EX_LTRREADING)
   pWindow->AddControl("CHECKBOX", pWindow->hWindow, IDC_FRMOPTIONSEDITOR_CHKCURRENTLINE, "Highlight current line", 0, 63, 179, 20, _
        WS_CHILD Or WS_VISIBLE Or WS_TABSTOP Or BS_TEXT Or BS_NOTIFY Or BS_AUTOCHECKBOX Or BS_LEFT Or BS_VCENTER, _
        WS_EX_LEFT Or WS_EX_LTRREADING)
   pWindow->AddControl("CHECKBOX", pWindow->hWindow, IDC_FRMOPTIONSEDITOR_CHKLINENUMBERING, "Show line numbers", 185, 42, 179, 20, _
        WS_CHILD Or WS_VISIBLE Or WS_TABSTOP Or BS_TEXT Or BS_NOTIFY Or BS_AUTOCHECKBOX Or BS_LEFT Or BS_VCENTER, _
        WS_EX_LEFT Or WS_EX_LTRREADING)
   pWindow->AddControl("CHECKBOX", pWindow->hWindow, IDC_FRMOPTIONSEDITOR_CHKCONFINECARET, "Confine caret to text", 0, 42, 179, 20, _
        WS_CHILD Or WS_VISIBLE Or WS_TABSTOP Or BS_TEXT Or BS_NOTIFY Or BS_AUTOCHECKBOX Or BS_LEFT Or BS_VCENTER, _
        WS_EX_LEFT Or WS_EX_LTRREADING)
   pWindow->AddControl("LABEL", pWindow->hWindow, IDC_FRMOPTIONSEDITOR_LBLLOCALIZATION, "English.lang", 14, 217, 206, 22, _
        WS_CHILD Or WS_VISIBLE Or WS_CLIPSIBLINGS Or WS_CLIPCHILDREN Or SS_CENTER Or SS_CENTERIMAGE Or SS_NOTIFY, _
        WS_EX_LEFT Or WS_EX_LTRREADING)
   pWindow->AddControl("BUTTON", pWindow->hWindow, IDC_FRMOPTIONSEDITOR_CMDLOCALIZATION, "Select", 255, 214, 69, 26, _
        WS_CHILD Or WS_VISIBLE Or WS_TABSTOP Or BS_TEXT Or BS_PUSHBUTTON Or BS_NOTIFY Or BS_CENTER Or BS_VCENTER, _
        WS_EX_LEFT Or WS_EX_LTRREADING)
   pWindow->AddControl("GROUPBOX", pWindow->hWindow, IDC_FRMOPTIONSEDITOR_FRAMELOCALIZATION, "Localization", 0, 198, 333, 50, _
        WS_CHILD Or WS_VISIBLE Or BS_TEXT Or BS_LEFT Or BS_NOTIFY Or BS_GROUPBOX, _
        WS_EX_TRANSPARENT Or WS_EX_LEFT Or WS_EX_LTRREADING)
   pWindow->AddControl("CHECKBOX", pWindow->hWindow, IDC_FRMOPTIONSEDITOR_CHKTABTOSPACES, "Treat Tab as spaces", 0, 83, 179, 20, _
        WS_CHILD Or WS_VISIBLE Or WS_TABSTOP Or BS_TEXT Or BS_NOTIFY Or BS_AUTOCHECKBOX Or BS_LEFT Or BS_VCENTER, _
        WS_EX_LEFT Or WS_EX_LTRREADING)
   pWindow->AddControl("CHECKBOX", pWindow->hWindow, IDC_FRMOPTIONSEDITOR_CHKMULTIPLEINSTANCES, "Allow multiple instances", 0, 104, 179, 20, _
        WS_CHILD Or WS_VISIBLE Or WS_TABSTOP Or BS_TEXT Or BS_NOTIFY Or BS_AUTOCHECKBOX Or BS_LEFT Or BS_VCENTER, _
        WS_EX_LEFT Or WS_EX_LTRREADING)
   pWindow->AddControl("CHECKBOX", pWindow->hWindow, IDC_FRMOPTIONSEDITOR_CHKAUTOINDENTATION, "Auto indentation", 0, 124, 179, 20, _
        WS_CHILD Or WS_VISIBLE Or WS_TABSTOP Or BS_TEXT Or BS_NOTIFY Or BS_AUTOCHECKBOX Or BS_LEFT Or BS_VCENTER, _
        WS_EX_LEFT Or WS_EX_LTRREADING)
   pWindow->AddControl("CHECKBOX", pWindow->hWindow, IDC_FRMOPTIONSEDITOR_CHKSHOWFOLDMARGIN, "Show fold margin", 185, 21, 179, 20, _
        WS_CHILD Or WS_VISIBLE Or WS_TABSTOP Or BS_TEXT Or BS_NOTIFY Or BS_AUTOCHECKBOX Or BS_LEFT Or BS_VCENTER, _
        WS_EX_LEFT Or WS_EX_LTRREADING)
   pWindow->AddControl("CHECKBOX", pWindow->hWindow, IDC_FRMOPTIONSEDITOR_CHKCOMPILEAUTOSAVE, "Autosave files before compiling", 0, 144, 235, 20, _
        WS_CHILD Or WS_VISIBLE Or WS_TABSTOP Or BS_TEXT Or BS_NOTIFY Or BS_AUTOCHECKBOX Or BS_LEFT Or BS_VCENTER, _
        WS_EX_LEFT Or WS_EX_LTRREADING)
   pWindow->AddControl("CHECKBOX", pWindow->hWindow, IDC_FRMOPTIONSEDITOR_CHKINDENTGUIDES, "Show Indentation guides", 185, 64, 179, 20, _
        WS_CHILD Or WS_VISIBLE Or WS_TABSTOP Or BS_TEXT Or BS_NOTIFY Or BS_AUTOCHECKBOX Or BS_LEFT Or BS_VCENTER, _
        WS_EX_LEFT Or WS_EX_LTRREADING)

   Function = 0

End Function


it works.

José Roca

#13
I have suspected that something was wrong (with the compiler?) playing with my tab control example.

If I do this, it works fine


' // Create the first tab page
DIM pTabPage1 AS CTabPage PTR = NEW CTabPage
pTabPage1->SetFont("", 14, FW_BOLD)
pTabPage1->InsertPage(hTab, 0, "Tab 1", -1, @TabPage1_WndProc)

' // Create the second tab page
DIM pTabPage2 AS CTabPage PTR = NEW CTabPage
pTabPage2->SetFont("", 12, FW_BOLD)
pTabPage2->InsertPage(hTab, 1, "Tab 2", -1, @TabPage2_WndProc)


But I did a mistake and instead of pTabPage2->SetFont("", 12, FW_BOLD), I used pTabPage1->SetFont("", 12, FW_BOLD)


' // Create the first tab page
DIM pTabPage1 AS CTabPage PTR = NEW CTabPage
pTabPage1->SetFont("", 14, FW_BOLD)
pTabPage1->InsertPage(hTab, 0, "Tab 1", -1, @TabPage1_WndProc)

' // Create the second tab page
DIM pTabPage2 AS CTabPage PTR = NEW CTabPage
pTabPage1->SetFont("", 12, FW_BOLD)
pTabPage2->InsertPage(hTab, 1, "Tab 2", -1, @TabPage2_WndProc)


and then it happened the same that with your code.

José Roca

#14
Why using pTabPage1->SetFont("", 12, FW_BOLD) after DIM pTabPage2 AS CTabPage PTR = NEW CTabPage causes problems?

Why moving the window creation from frmOptionsEditor_Show to frmOptions.inc works?

Looks like a compiler bug to me.