multitab editor

(Updates to FBSL Editors, RAD and Related Stuff)

Unread postby Mike Lobanovsky » Tue Mar 21, 2006 6:03 pm

OK folks,

I've sent my mods to Gerome so shortly you'll be able to run and modify this template to your liking:
User avatar
Mike Lobanovsky
FBSL Administrator
FBSL Administrator
 
Posts: 1823
Joined: Tue Apr 19, 2005 8:22 am
Location: Republic of Belarus

Unread postby Gerome » Wed Mar 22, 2006 12:14 am

Dear all,

Mike Lobanovsky wrote:OK folks,

I've sent my mods to Gerome so shortly you'll be able to run and modify this template to your liking:


Yup!
Get the 3.20.2 version and it'll work as Mike's expected ;)
Very powerful sample !!!
It shows the power we can have from MDI interfaces!
Yours,

(¯`·._.·[Gerome GUILLEMIN]·._.·´¯)
:: Full SETUP w. HELP 05th of December 2011 ::
http://www.fbsl.net/setup/FBSLv3.exe [full v3.4.10 installation pack]
http://www.fbsl.net/setup/FBSLv3bin.zip [minimal upgrade to v3.4.10]
Laissons les jolies femmes aux hommes sans imagination. / Let us leave pretty women to men without imagination.(M.Proust)
The success is a defeat for the one who does not want to dance any more! (H.F. Thiefaine)
User avatar
Gerome
FBSL Administrator
FBSL Administrator
 
Posts: 3149
Joined: Sat Mar 12, 2005 9:06 pm
Location: Paris -- France

Unread postby Mike Lobanovsky » Wed Mar 29, 2006 5:28 pm

Hey Ferdinand,

How are things going with the new MDI and your code?

Mike
User avatar
Mike Lobanovsky
FBSL Administrator
FBSL Administrator
 
Posts: 1823
Joined: Tue Apr 19, 2005 8:22 am
Location: Republic of Belarus

Unread postby ferdinad_piatnik » Thu Mar 30, 2006 11:08 pm

Mike Lobanovsky wrote:Hey Ferdinand,

How are things going with the new MDI and your code?

Mike


Hi!

I don't have much time these days. I've made use of your template for building toolbar. Now icon buttons look professional and tooltips work correctlly.
I've noticed that it is not good idea to use Destroy function to close child windows.
But there are still lot of details to investigate.

best regards
User avatar
ferdinad_piatnik
FBSL geek
FBSL geek
 
Posts: 139
Joined: Wed Feb 01, 2006 11:12 pm
Location: Slovenia

Unread postby Mike Lobanovsky » Fri Mar 31, 2006 8:18 am

Hi Ferdinand,

I didn't suggest using Destroy or whatever. The template uses
PostMessage(MDIGetActiveChild(), WM_CLOSE, 0, 0)


FBSL is made to handle the WM_CLOSE message intrinsically so this is the most safe method to close FBSL windows programmatically ensuring all of the intrinsic closing sequences and procedures are executed correctly and in proper order.

Mike
User avatar
Mike Lobanovsky
FBSL Administrator
FBSL Administrator
 
Posts: 1823
Joined: Tue Apr 19, 2005 8:22 am
Location: Republic of Belarus

Unread postby ferdinad_piatnik » Fri Mar 31, 2006 10:00 pm

Mike Lobanovsky wrote:I didn't suggest using Destroy or whatever.

Well, I didn't suggest that you did suggest it. It's just the way how I used to close windows before MDI. It worked without visible side effects, but it's not a valid method in this situation. I want to intercept "close" request from user and then decide whether to fulfil it or not.

If the request is caused by button or menu item than there is no problem. But if the user clicks X in the upper right corner of the window I guess it will trigger the same event as sending WM_CLOSE message. But perhaps I'm talking nonsense now. I really have to spend more time testing.

Best regards
User avatar
ferdinad_piatnik
FBSL geek
FBSL geek
 
Posts: 139
Joined: Wed Feb 01, 2006 11:12 pm
Location: Slovenia

Unread postby Gerome » Fri Mar 31, 2006 10:56 pm

Hello,

Me and MDI can be then totally controlled via the WM_CLOSE interception like the following sample tries to demonstrate...

Code: Select all
$AppType MDI
#Option Explicit

Dim %MainMenu = CreateMenu()
Dim %FileMenu = CreateMenu()
Dim %WindowMenu = CreateMenu()
AppendMenu(FileMenu, MF_STRING, 101, "&New")
AppendMenu(MainMenu, MF_POPUP, FileMenu, "&File")

MDIForm("My MDI Form", 100, 100, 600, 400, MainMenu, WindowMenu)
Center(ME)
Show(ME)

Begin Events
   Select Case CBMSG
      Case WM_COMMAND
         If CBLPARAM = 0 Then
            If CBWPARAM = 101 Then
               MDIChildForm()
               Return 0
                End If
         End If
         Case WM_CLOSE
            Msgbox(0, "Me = " & $Me, "Active MDI = " & $MDIGetActiveChild(), 0)
            Exitprogram(0) '// Do what you want here :)
   End Select
End Events


Hope this helps you!
Yours,

(¯`·._.·[Gerome GUILLEMIN]·._.·´¯)
:: Full SETUP w. HELP 05th of December 2011 ::
http://www.fbsl.net/setup/FBSLv3.exe [full v3.4.10 installation pack]
http://www.fbsl.net/setup/FBSLv3bin.zip [minimal upgrade to v3.4.10]
Laissons les jolies femmes aux hommes sans imagination. / Let us leave pretty women to men without imagination.(M.Proust)
The success is a defeat for the one who does not want to dance any more! (H.F. Thiefaine)
User avatar
Gerome
FBSL Administrator
FBSL Administrator
 
Posts: 3149
Joined: Sat Mar 12, 2005 9:06 pm
Location: Paris -- France

Unread postby Mike Lobanovsky » Sat Apr 01, 2006 10:44 am

Yes Ferdinand,

Just evaluate the CBHWND value in Case WM_CLOSE to take the decision what to do with the window that wants to close. If you Return 0 upon evaluation, the window will not close.

All child window messages also go into the Begin/End Events loop without any additional subclassing. To differentiate between them, compare CBHWND to ME, to MDIGetActiveChild, etc.

Mike
User avatar
Mike Lobanovsky
FBSL Administrator
FBSL Administrator
 
Posts: 1823
Joined: Tue Apr 19, 2005 8:22 am
Location: Republic of Belarus

Problems with WM_CLOSE

Unread postby ferdinad_piatnik » Sat Apr 01, 2006 10:12 pm

Hi Gerome, Mike! (sorted by Ascii)

I changed Gerome's example to fit my needs (intentions). I tried to follow Mike's instructions how to control intercepted WM_CLOSE events messages). The window just doesn't close. I don't get it. Too many beers all those years.
I didn't put any comments into the example- I hope it's obvious(otherwise I have a problem)
If you can point out my error I'd be very thankfull - otherwise I'll have to dig the MSDN site ( and I don't feel like it )

best regards

Code: Select all
#Option Explicit
$AppType MDI
$AppType CONSOLE

Begin Enum
   ID_New=100
   ID_Close
End Enum
Dim $text,%newWin
Dim %MainMenu = CreateMenu()
Dim %FileMenu = CreateMenu()
Dim %WindowMenu = CreateMenu()
AppendMenu(FileMenu, MF_STRING, ID_New, "&New")
AppendMenu(FileMenu, MF_STRING, ID_Close, "&Close")
AppendMenu(MainMenu, MF_POPUP, FileMenu, "&File")
AppendMenu(MainMenu, MF_POPUP, WindowMenu, "&Window")

MDIForm("My MDI Form", 100, 100, 600, 400, MainMenu, WindowMenu)
Center(Me)
Show(Me)
Begin Events
   Select Case CBMSG
      Case WM_COMMAND
         If CBLPARAM = 0 Then
            If CBWPARAM = ID_New Then
               newWin = MDIChildForm()
               Print "Menu command: New(" & newWin & ")"
               Fbsl_SetText(newWin,"Child window " & newWin)
               Return 0
            End If
            If CBWPARAM = ID_Close Then
               Print "Menu command: Close"
               PostMessage(MDIGetActiveChild(), WM_CLOSE, 0, 0)
            End If
         End If
      Case WM_CLOSE
         If CBHWND=Me Then
            text="main"
         Else
            text="child"
         End If
         text = text & "window(" & CBHWND & ")"
         Print "WM_CLOSE event:Close " & text 
         If 6<>MsgBox(0, "Do you really want to close " & text & "?",_
               "Close", MB_YESNO + MB_ICONWARNING) Then
            Print "No way, punk!"
            Return(0)
         Else
            Print "As you wish, master!"
            Return(1)
          End If
   End Select
End Events
[/code]
Last edited by ferdinad_piatnik on Sat Apr 01, 2006 11:07 pm, edited 1 time in total.
User avatar
ferdinad_piatnik
FBSL geek
FBSL geek
 
Posts: 139
Joined: Wed Feb 01, 2006 11:12 pm
Location: Slovenia

Re: Problems with WM_CLOSE

Unread postby Gerome » Sat Apr 01, 2006 10:37 pm

Ferdinand,

Simply replace
Return 1
with :
Destroy( CBHWND )

It'll send the corresponding message telling Fbsl to let the wanted window to be closed correctly!
Yours,

(¯`·._.·[Gerome GUILLEMIN]·._.·´¯)
:: Full SETUP w. HELP 05th of December 2011 ::
http://www.fbsl.net/setup/FBSLv3.exe [full v3.4.10 installation pack]
http://www.fbsl.net/setup/FBSLv3bin.zip [minimal upgrade to v3.4.10]
Laissons les jolies femmes aux hommes sans imagination. / Let us leave pretty women to men without imagination.(M.Proust)
The success is a defeat for the one who does not want to dance any more! (H.F. Thiefaine)
User avatar
Gerome
FBSL Administrator
FBSL Administrator
 
Posts: 3149
Joined: Sat Mar 12, 2005 9:06 pm
Location: Paris -- France

Re: Problems with WM_CLOSE

Unread postby ferdinad_piatnik » Sat Apr 01, 2006 11:16 pm

Gerome wrote:Ferdinand,

Simply replace
Return 1
with :
Destroy( CBHWND )

It'll send the corresponding message telling Fbsl to let the wanted window to be closed correctly!

Okay!
You are absolutely right. Now window closes.
I added Window menu to the example (I forgot before). The list of currently opened child windows somehow doesn't cooperate with Destroy command, at least on my computer. This was the reason why I said before that Destroy command is no longer good enough( I wasn't quite clear, heh :oops: ).

best regards
User avatar
ferdinad_piatnik
FBSL geek
FBSL geek
 
Posts: 139
Joined: Wed Feb 01, 2006 11:12 pm
Location: Slovenia

Unread postby ferdinad_piatnik » Sat Apr 01, 2006 11:45 pm

Hi!
I updated myEdit with real toolbar (as Mike suggested) but still with no comments and badly structured.
With FBSL evolving so quickly the embedded FBSL language definition in the CS30.dll has become somehow out of date. But that's out of my league.

best regards

*** new version 4.4.2006
Last edited by ferdinad_piatnik on Tue Apr 04, 2006 10:59 pm, edited 1 time in total.
User avatar
ferdinad_piatnik
FBSL geek
FBSL geek
 
Posts: 139
Joined: Wed Feb 01, 2006 11:12 pm
Location: Slovenia

Unread postby Mike Lobanovsky » Mon Apr 03, 2006 9:54 am

Hi Gerome,

Do not use Destroy() in the WM_CLOSE case for MDI child windows. It bypasses the natural order of message processing in the automatic list of child windows, that's why the list isn't updated (the corresponding entry is not removed).

Hi Ferdinand,

Consider this:
Code: Select all
#Option Explicit
$AppType MDI
$AppType CONSOLE

Begin Enum
   ID_New=100
   ID_Close
End Enum
Dim $text,%newWin
Dim %MainMenu = CreateMenu()
Dim %FileMenu = CreateMenu()
Dim %WindowMenu = CreateMenu()
AppendMenu(FileMenu, MF_STRING, ID_New, "&New")
AppendMenu(FileMenu, MF_STRING, ID_Close, "&Close")
AppendMenu(MainMenu, MF_POPUP, FileMenu, "&File")
AppendMenu(MainMenu, MF_POPUP, WindowMenu, "&Window")

MDIForm("My MDI Form", 100, 100, 600, 400, MainMenu, WindowMenu)
Center(Me)
Show(Me)
Begin Events
dim %hwnd,%msg,%wparam,%lparam
   Select Case CBMSG
      Case WM_COMMAND
         If CBLPARAM = 0 Then
            If CBWPARAM = ID_New Then
               newWin = MDIChildForm()
               Print "Menu command: New(" & newWin & ")"
               Fbsl_SetText(newWin,"Child window " & newWin)
               Return 0
            End If
            If CBWPARAM = ID_Close Then
               Print "Menu command: Close"
               PostMessage(MDIGetActiveChild(), WM_CLOSE, 0, 0)
            End If
         End If
      Case WM_CLOSE
hwnd=cbhwnd:msg=cbmsg:wparam=cbwparam:lparam=cblparam
         If CBHWND=Me Then
            text="main"
         Else
            text="child"
         End If
         text = text & "window(" & CBHWND & ")"
         Print "WM_CLOSE event:Close " & text
         If 6<>MsgBox(0, "Do you really want to close " & text & "?",_
               "Close", MB_YESNO + MB_ICONWARNING) Then
            Print "No way, punk!"
            Return 0
         Else
            Print "As you wish, master!"
cbhwnd=hwnd:cbmsg=msg:cbwparam=wparam:cblparam=lparam
            'Return 1
         End If
   End Select
End Events


1. Use Return X only to tell Windows that you have handled the corresponding message entirely yourself. The X value will depend upon the actual message. You'll need to consult MSDN for the necessary value each time you want to prevent Windows from doing the default processing. In this case, you want Windows to close the corresponding window, i.e. DO the default WM_CLOSE message processing, so don't use Return X at all.

2. Bringing the message box on screen generates other messages such as WM_SETFOCUS, WM_KILLFOCUS, WM_PAINT and lots of others that also go into the Begin/End Events loop. The fact that you don't handle them doesn't prevent CBHWND, CBMSG, CBWPARAM, CBLPARAM from changing accordingly. When the message box closes with the value of 6, you want Windows to carry on the default processing, i.e. continue closing the window. BUT THE CBHWND, CBMSG, CBWPARAM, CBLPARAM VALUES HAVE ALREADY CHANGED! You need to store them beforehand and restore them afterwards to achieve the desired result.

Just as simple as that... 8)

Mike :)
User avatar
Mike Lobanovsky
FBSL Administrator
FBSL Administrator
 
Posts: 1823
Joined: Tue Apr 19, 2005 8:22 am
Location: Republic of Belarus

Unread postby Gerome » Mon Apr 03, 2006 10:08 am

Hello Mike,

Mike Lobanovsky wrote:Hi Gerome,

1. Use Return X only to tell Windows that you have handled the corresponding message entirely yourself. The X value will depend upon the actual message. You'll need to consult MSDN for the necessary value each time you want to prevent Windows from doing the default processing. In this case, you want Windows to close the corresponding window, i.e. DO the default WM_CLOSE message processing, so don't use Return X at all.

2. Bringing the message box on screen generates other messages such as WM_SETFOCUS, WM_KILLFOCUS, WM_PAINT and lots of others that also go into the Begin/End Events loop. The fact that you don't handle them doesn't prevent CBHWND, CBMSG, CBWPARAM, CBLPARAM from changing accordingly. When the message box closes with the value of 6, you want Windows to carry on the default processing, i.e. continue closing the window. BUT THE CBHWND, CBMSG, CBWPARAM, CBLPARAM VALUES HAVE ALREADY CHANGED! You need to store them beforehand and restore them afterwards to achieve the desired result.

Just as simple as that... 8)

Mike :)


So, we can start to think to have an inner way of handling this 'problem' ?
That is to say saving and restoring CBxxx for the WM_CLOSE case because that case seems to be sensible isn't it ?
Yours,

(¯`·._.·[Gerome GUILLEMIN]·._.·´¯)
:: Full SETUP w. HELP 05th of December 2011 ::
http://www.fbsl.net/setup/FBSLv3.exe [full v3.4.10 installation pack]
http://www.fbsl.net/setup/FBSLv3bin.zip [minimal upgrade to v3.4.10]
Laissons les jolies femmes aux hommes sans imagination. / Let us leave pretty women to men without imagination.(M.Proust)
The success is a defeat for the one who does not want to dance any more! (H.F. Thiefaine)
User avatar
Gerome
FBSL Administrator
FBSL Administrator
 
Posts: 3149
Joined: Sat Mar 12, 2005 9:06 pm
Location: Paris -- France

Unread postby Mike Lobanovsky » Mon Apr 03, 2006 10:16 am

No Gerome,

This is not a problem. This is how Windows operates. Just remember that there are more than 800 standard window messages and some of them need CBMSG,CBHWND,CBWPARAM,CBLPARAM values set/modified by the user.

You just have to be more considerate when doing something in the Events loop. Many of your actions may have side effects in the way of messages that you overlook and don't handle.

Mike :)
User avatar
Mike Lobanovsky
FBSL Administrator
FBSL Administrator
 
Posts: 1823
Joined: Tue Apr 19, 2005 8:22 am
Location: Republic of Belarus

PreviousNext

Return to FBSL v3 Editors

Who is online

Users browsing this forum: No registered users and 1 guest