Version 1.7.5 (August 22, 2018)
- Added: OptionButton toolbox control.
- Added: Frame toolbox control.
- Added: Implemented logic for controls "Locked" property.
- Added: Implemented logic for top menu option "Lock Controls" (this is a global override locking the form and all controls on the form).
- Added: Pasting controls automatically increments the TabIndex property for the newly created controls.
- Added: Entering an existing TabIndex number will automatically re-number all higher TabIndex value controls.
- Changed: Greatly refactored the underlying WinFormsX code dealing with the message pump and keyboard input handling and modal/modeless forms.
- Fixed: Pasting controls was not immediately setting the form dirty thereby not saving the changes.
- Fixed: Dropdown combobox in ToolBox that displays list of controls for the form was not updating when controls deleted from the form.
- Fixed: AutoInsert inserting "End Function" and/or "End Sub" in situations when it should not. Fix from 1.7.4 failed on "FUNCTION =" lines.
- Fixed: Keyboard focus is now correctly restored when a popup modal form is closed.
https://github.com/PaulSquires/WinFBE/releases
Hi Paul,
Why is it that for the frame, background refers to the text, whereas for a label, background fills the whole label? I'm also wondering what the differances are between labels and buttons, since the appearance of each and events are more or less the same. Come to think of it, why not just have forms?
Experimenting with the idea of labels instead of buttons, if you mousedown and mouseup a few times on a label, (at button clicking speed) then the program shuts down.
Quote from: raymw on August 23, 2018, 07:11:16 PM
Hi Paul,
Why is it that for the frame, background refers to the text, whereas for a label, background fills the whole label? I'm also wondering what the differances are between labels and buttons, since the appearance of each and events are more or less the same. Come to think of it, why not just have forms?
That's the way Windows API works. A "Frame" in WinFBE is simply a button with BS_GROUPBOX style. In other IDE's like Visual Studio, Visual Basic, etc... a Frame control is implemented as a custom control and acts like a container where you can place other controls inside of it and move them and act on them like a self contained group. In WinAPI, a BS_GROUPBOX styled button always only changes the background color of the text of the frame (not the frame background). Likewise, you can not change the forecolor of the text unless the Windows Themes are disabled. You can not change the forecolor of CheckBoxes or OptionButtons either. See, Windows can be a funny beast. The best solution would be for me to implement all controls as custom controls or ownerdrawn controls so I can apply any style I want and have complete freedom. Sadly, that is a tremendous amount of work and I am only one person. You can see the benefits by the case of WinFBE using Jose's CXpButton as a replacement for the standard Windows button - it is so much more flexible.
Quote from: raymw on August 23, 2018, 08:01:56 PM
Experimenting with the idea of labels instead of buttons, if you mousedown and mouseup a few times on a label, (at button clicking speed) then the program shuts down.
This must have something to do with code that you have attached to those mouse events for the label? I have clicked on a label on my form a thousand times and there was no GPF.
Quote from: raymw on August 23, 2018, 07:11:16 PM
I'm also wondering what the differances are between labels and buttons, since the appearance of each and events are more or less the same. Come to think of it, why not just have forms?
Labels are meant to be static displays of text. They do not receive keyboard focus. Normally they do not respond to mouse clicks although in WinFBE I have enabled the SS_NOTIFY style so mouse clicks can be captured. I add the other mouse events as a convenience. Labels are more lightweight than a button control. You can use buttons to act like a label control. Buttons give a better visual appearance and visual movement as it is being clicked. Likewise, buttons receive keyboard input focus which is critical. Not sure what you mean by "...why not just have forms".
Hi Paul,
Thanks for your replies.
Here is the simple complete 'testlabel.bas file. Clicking on label1 a few fastish times crashes the program. I've included the whole thing, instead of just my label/button code, in case it gives you a clue as to why it crashes.(It just changes the background color, to indicate mouse up or down)' WINFBE FORM
' WINFBE VERSION 1.7.5
' LOCKCONTROLS=False
' WINFBE FORM_START
' WINFBE CONTROL_START Form
' PROPERTIES_START
' PROP_NAME=Name
' PROP_VALUE=Form1
' PROP_NAME=Left
' PROP_VALUE=10
' PROP_NAME=Top
' PROP_VALUE=10
' PROP_NAME=Width
' PROP_VALUE=500
' PROP_NAME=Height
' PROP_VALUE=300
' PROP_NAME=Text
' PROP_VALUE=Form1
' PROP_NAME=WindowState
' PROP_VALUE=FormWindowState.Normal
' PROP_NAME=StartPosition
' PROP_VALUE=FormStartPosition.Manual
' PROP_NAME=BorderStyle
' PROP_VALUE=FormBorderStyle.Sizable
' PROP_NAME=MinimizeBox
' PROP_VALUE=True
' PROP_NAME=MaximizeBox
' PROP_VALUE=True
' PROP_NAME=ControlBox
' PROP_VALUE=True
' PROP_NAME=Enabled
' PROP_VALUE=True
' PROP_NAME=Visible
' PROP_VALUE=True
' PROP_NAME=BackColor
' PROP_VALUE=SYSTEM|Control
' PROP_NAME=AcceptButton
' PROP_VALUE=
' PROP_NAME=AllowDrop
' PROP_VALUE=False
' PROP_NAME=KeyPreview
' PROP_VALUE=False
' PROP_NAME=CancelButton
' PROP_VALUE=
' PROP_NAME=Locked
' PROP_VALUE=False
' PROP_NAME=MaximumHeight
' PROP_VALUE=0
' PROP_NAME=MaximumWidth
' PROP_VALUE=0
' PROP_NAME=MinimumHeight
' PROP_VALUE=0
' PROP_NAME=MinimumWidth
' PROP_VALUE=0
' PROP_NAME=ShowInTaskBar
' PROP_VALUE=True
' PROP_NAME=Tag
' PROP_VALUE=
' PROPERTIES_END
' EVENTS_START
' EVENTS_END
' WINFBE CONTROL_END
' WINFBE CONTROL_START Label
' PROPERTIES_START
' PROP_NAME=Name
' PROP_VALUE=Label1
' PROP_NAME=Left
' PROP_VALUE=52
' PROP_NAME=Top
' PROP_VALUE=68
' PROP_NAME=Width
' PROP_VALUE=112
' PROP_NAME=Height
' PROP_VALUE=48
' PROP_NAME=Text
' PROP_VALUE=Label1
' PROP_NAME=AllowDrop
' PROP_VALUE=False
' PROP_NAME=BackColor
' PROP_VALUE=SYSTEM|Control
' PROP_NAME=ForeColor
' PROP_VALUE=SYSTEM|ControlText
' PROP_NAME=BorderStyle
' PROP_VALUE=ControlBorderStyle.None
' PROP_NAME=TextAlign
' PROP_VALUE=LabelAlignment.TopLeft
' PROP_NAME=Font
' PROP_VALUE=Segoe UI,9,400,0,0,0,1
' PROP_NAME=Enabled
' PROP_VALUE=True
' PROP_NAME=Tag
' PROP_VALUE=
' PROP_NAME=Locked
' PROP_VALUE=False
' PROP_NAME=UseMnemonic
' PROP_VALUE=True
' PROP_NAME=Visible
' PROP_VALUE=True
' PROPERTIES_END
' EVENTS_START
' EVENT_NAME=MouseDown
' EVENT_NAME=MouseUp
' EVENTS_END
' WINFBE CONTROL_END
' WINFBE CONTROL_START Label
' PROPERTIES_START
' PROP_NAME=Name
' PROP_VALUE=Label2
' PROP_NAME=Left
' PROP_VALUE=278
' PROP_NAME=Top
' PROP_VALUE=69
' PROP_NAME=Width
' PROP_VALUE=117
' PROP_NAME=Height
' PROP_VALUE=54
' PROP_NAME=Text
' PROP_VALUE=Label2
' PROP_NAME=AllowDrop
' PROP_VALUE=False
' PROP_NAME=BackColor
' PROP_VALUE=SYSTEM|Control
' PROP_NAME=ForeColor
' PROP_VALUE=SYSTEM|ControlText
' PROP_NAME=BorderStyle
' PROP_VALUE=ControlBorderStyle.None
' PROP_NAME=TextAlign
' PROP_VALUE=LabelAlignment.TopLeft
' PROP_NAME=Font
' PROP_VALUE=Segoe UI,9,400,0,0,0,1
' PROP_NAME=Enabled
' PROP_VALUE=True
' PROP_NAME=Tag
' PROP_VALUE=
' PROP_NAME=Locked
' PROP_VALUE=False
' PROP_NAME=UseMnemonic
' PROP_VALUE=True
' PROP_NAME=Visible
' PROP_VALUE=True
' PROPERTIES_END
' EVENTS_START
' EVENTS_END
' WINFBE CONTROL_END
' WINFBE FORM_END
' WINFBE_CODEGEN_START
#include once "WinFormsX\WinFormsX.bi"
Declare Function Form1_Label1_MouseDown( ByRef sender As wfxLabel, ByRef e As EventArgs ) As LRESULT
Declare Function Form1_Label1_MouseUp( ByRef sender As wfxLabel, ByRef e As EventArgs ) As LRESULT
type Form1Type extends wfxForm
private:
temp as byte
public:
declare constructor
' Controls
Label1 As wfxLabel
Label2 As wfxLabel
end type
constructor Form1Type
this.Text = "Form1"
this.SetBounds(10,10,500,300)
this.Label1.Parent = @this
this.Label1.Text = "Label1"
this.Label1.SetBounds(52,68,112,48)
this.Label1.OnMouseDown = @Form1_Label1_MouseDown
this.Label1.OnMouseUp = @Form1_Label1_MouseUp
this.Label2.Parent = @this
this.Label2.Text = "Label2"
this.Label2.SetBounds(278,69,117,54)
this.Controls.Add(ControlType.Label, @this.Label1)
this.Controls.Add(ControlType.Label, @this.Label2)
Application.Forms.Add(ControlType.Form, @this)
end constructor
dim shared Form1 as Form1Type
' WINFBE_CODEGEN_END
''
'' Remove the following Application.Run code if it used elsewhere in your application.
Application.Run(Form1)
''
''
Function Form1_Label1_MouseDown( ByRef sender As wfxLabel, ByRef e As EventArgs ) As LRESULT
form1.label1.BackColor=colors.red
Function = 0
End Function
''
''
Function Form1_Label1_MouseUp( ByRef sender As wfxLabel, ByRef e As EventArgs ) As LRESULT
form1.label1.BackColor=colors.blue
Function = 0
End Function
Best wishes,
Ray
Here's another gotcha. - at least for me.
Extending on my previous problem, let's compare with button behavior
''
'' Remove the following Application.Run code if it used elsewhere in your application.
Application.Run(Form1)
dim shared count as integer
dim shared bcount as integer
''
''
Function Form1_Label1_MouseDown( ByRef sender As wfxLabel, ByRef e As EventArgs ) As LRESULT
form1.label1.BackColor=colors.red
count=count+1
form1.label2.Text= form1.Label2.text + " try"+ str(count)
Function = 0
End Function
''
''
Function Form1_Label1_MouseUp( ByRef sender As wfxLabel, ByRef e As EventArgs ) As LRESULT
form1.label1.BackColor=colors.blue
Function = 0
End Function
''
Function Form1_Load( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT
count=0
bcount=0
Function = 0
End Function
''
''
Function Form1_Button1_MouseDown( ByRef sender As wfxButton, ByRef e As EventArgs ) As LRESULT
form1.button1.BackColor=colors.red
bcount=bcount+1
form1.button2.Text= form1.button2.text + " try"+ str(bcount)
Function = 0
End Function
''
''
Function Form1_Button1_MouseUp( ByRef sender As wfxButton, ByRef e As EventArgs ) As LRESULT
form1.button1.BackColor=colors.blue
Function = 0
End Function
using the mouse, slowly clicking on label 1, color changes and text added to lavbel 2, until label area gets full (or maybe some other limit I've not tested). This behaves exactly as I'd expect. I would think a button would be the same. So, I added a couple of buttons. Clicking on button1, color only changes on leaving button1, and button2 text only updates when mouse enters button2. This is not what I'd expect. Labels are better...
After version 1.7.3, there is such a problem: strange characters appear at the end of the Chinese menu and prompts, such as: 工具 (T) M, where M is redundant. Looking for the source code, it should be a problem with Mid, because it uses CWStr, so you need to use CWStr's MidChars function, I made such a modification, the display is normal:
'wData = Mid(wst, i+1)
wData = wst.MidChars(i+1)
In addition, thank you for your efforts and look forward to new progress.
Quote from: raymw on August 24, 2018, 12:11:21 PM
Here's another gotcha. - at least for me.
Extending on my previous problem, let's compare with button behavior
''
'' Remove the following Application.Run code if it used elsewhere in your application.
Application.Run(Form1)
dim shared count as integer
dim shared bcount as integer
''
''
Function Form1_Label1_MouseDown( ByRef sender As wfxLabel, ByRef e As EventArgs ) As LRESULT
form1.label1.BackColor=colors.red
count=count+1
form1.label2.Text= form1.Label2.text + " try"+ str(count)
Function = 0
End Function
''
''
Function Form1_Label1_MouseUp( ByRef sender As wfxLabel, ByRef e As EventArgs ) As LRESULT
form1.label1.BackColor=colors.blue
Function = 0
End Function
''
Function Form1_Load( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT
count=0
bcount=0
Function = 0
End Function
''
''
Function Form1_Button1_MouseDown( ByRef sender As wfxButton, ByRef e As EventArgs ) As LRESULT
form1.button1.BackColor=colors.red
bcount=bcount+1
form1.button2.Text= form1.button2.text + " try"+ str(bcount)
Function = 0
End Function
''
''
Function Form1_Button1_MouseUp( ByRef sender As wfxButton, ByRef e As EventArgs ) As LRESULT
form1.button1.BackColor=colors.blue
Function = 0
End Function
using the mouse, slowly clicking on label 1, color changes and text added to lavbel 2, until label area gets full (or maybe some other limit I've not tested). This behaves exactly as I'd expect. I would think a button would be the same. So, I added a couple of buttons. Clicking on button1, color only changes on leaving button1, and button2 text only updates when mouse enters button2. This is not what I'd expect. Labels are better...
Yeah, something seems odd there. I need to trace the sequence of messages between Windows and the CXpButton control. Also, in MouseDown you should probably be setting the BackColorDown property rather than the BackColor property. Have you tried setting the properties via the PropertyList to see if gives you the result you are looking for when the mouse is pressed and released (by setting the properties in the Property List, BackColor, BackColorDown, etc).
Quote from: raymw on August 24, 2018, 11:35:46 AM
Hi Paul,
Thanks for your replies.
Here is the simple complete 'testlabel.bas file. Clicking on label1 a few fastish times crashes the program. I've included the whole thing, instead of just my label/button code, in case it gives you a clue as to why it crashes.(It just changes the background color, to indicate mouse up or down)' WINFBE FORM
' WINFBE VERSION 1.7.5
' LOCKCONTROLS=False
' WINFBE FORM_START
' WINFBE CONTROL_START Form
' PROPERTIES_START
' PROP_NAME=Name
' PROP_VALUE=Form1
' PROP_NAME=Left
' PROP_VALUE=10
' PROP_NAME=Top
' PROP_VALUE=10
' PROP_NAME=Width
' PROP_VALUE=500
' PROP_NAME=Height
' PROP_VALUE=300
' PROP_NAME=Text
' PROP_VALUE=Form1
' PROP_NAME=WindowState
' PROP_VALUE=FormWindowState.Normal
' PROP_NAME=StartPosition
' PROP_VALUE=FormStartPosition.Manual
' PROP_NAME=BorderStyle
' PROP_VALUE=FormBorderStyle.Sizable
' PROP_NAME=MinimizeBox
' PROP_VALUE=True
' PROP_NAME=MaximizeBox
' PROP_VALUE=True
' PROP_NAME=ControlBox
' PROP_VALUE=True
' PROP_NAME=Enabled
' PROP_VALUE=True
' PROP_NAME=Visible
' PROP_VALUE=True
' PROP_NAME=BackColor
' PROP_VALUE=SYSTEM|Control
' PROP_NAME=AcceptButton
' PROP_VALUE=
' PROP_NAME=AllowDrop
' PROP_VALUE=False
' PROP_NAME=KeyPreview
' PROP_VALUE=False
' PROP_NAME=CancelButton
' PROP_VALUE=
' PROP_NAME=Locked
' PROP_VALUE=False
' PROP_NAME=MaximumHeight
' PROP_VALUE=0
' PROP_NAME=MaximumWidth
' PROP_VALUE=0
' PROP_NAME=MinimumHeight
' PROP_VALUE=0
' PROP_NAME=MinimumWidth
' PROP_VALUE=0
' PROP_NAME=ShowInTaskBar
' PROP_VALUE=True
' PROP_NAME=Tag
' PROP_VALUE=
' PROPERTIES_END
' EVENTS_START
' EVENTS_END
' WINFBE CONTROL_END
' WINFBE CONTROL_START Label
' PROPERTIES_START
' PROP_NAME=Name
' PROP_VALUE=Label1
' PROP_NAME=Left
' PROP_VALUE=52
' PROP_NAME=Top
' PROP_VALUE=68
' PROP_NAME=Width
' PROP_VALUE=112
' PROP_NAME=Height
' PROP_VALUE=48
' PROP_NAME=Text
' PROP_VALUE=Label1
' PROP_NAME=AllowDrop
' PROP_VALUE=False
' PROP_NAME=BackColor
' PROP_VALUE=SYSTEM|Control
' PROP_NAME=ForeColor
' PROP_VALUE=SYSTEM|ControlText
' PROP_NAME=BorderStyle
' PROP_VALUE=ControlBorderStyle.None
' PROP_NAME=TextAlign
' PROP_VALUE=LabelAlignment.TopLeft
' PROP_NAME=Font
' PROP_VALUE=Segoe UI,9,400,0,0,0,1
' PROP_NAME=Enabled
' PROP_VALUE=True
' PROP_NAME=Tag
' PROP_VALUE=
' PROP_NAME=Locked
' PROP_VALUE=False
' PROP_NAME=UseMnemonic
' PROP_VALUE=True
' PROP_NAME=Visible
' PROP_VALUE=True
' PROPERTIES_END
' EVENTS_START
' EVENT_NAME=MouseDown
' EVENT_NAME=MouseUp
' EVENTS_END
' WINFBE CONTROL_END
' WINFBE CONTROL_START Label
' PROPERTIES_START
' PROP_NAME=Name
' PROP_VALUE=Label2
' PROP_NAME=Left
' PROP_VALUE=278
' PROP_NAME=Top
' PROP_VALUE=69
' PROP_NAME=Width
' PROP_VALUE=117
' PROP_NAME=Height
' PROP_VALUE=54
' PROP_NAME=Text
' PROP_VALUE=Label2
' PROP_NAME=AllowDrop
' PROP_VALUE=False
' PROP_NAME=BackColor
' PROP_VALUE=SYSTEM|Control
' PROP_NAME=ForeColor
' PROP_VALUE=SYSTEM|ControlText
' PROP_NAME=BorderStyle
' PROP_VALUE=ControlBorderStyle.None
' PROP_NAME=TextAlign
' PROP_VALUE=LabelAlignment.TopLeft
' PROP_NAME=Font
' PROP_VALUE=Segoe UI,9,400,0,0,0,1
' PROP_NAME=Enabled
' PROP_VALUE=True
' PROP_NAME=Tag
' PROP_VALUE=
' PROP_NAME=Locked
' PROP_VALUE=False
' PROP_NAME=UseMnemonic
' PROP_VALUE=True
' PROP_NAME=Visible
' PROP_VALUE=True
' PROPERTIES_END
' EVENTS_START
' EVENTS_END
' WINFBE CONTROL_END
' WINFBE FORM_END
' WINFBE_CODEGEN_START
#include once "WinFormsX\WinFormsX.bi"
Declare Function Form1_Label1_MouseDown( ByRef sender As wfxLabel, ByRef e As EventArgs ) As LRESULT
Declare Function Form1_Label1_MouseUp( ByRef sender As wfxLabel, ByRef e As EventArgs ) As LRESULT
type Form1Type extends wfxForm
private:
temp as byte
public:
declare constructor
' Controls
Label1 As wfxLabel
Label2 As wfxLabel
end type
constructor Form1Type
this.Text = "Form1"
this.SetBounds(10,10,500,300)
this.Label1.Parent = @this
this.Label1.Text = "Label1"
this.Label1.SetBounds(52,68,112,48)
this.Label1.OnMouseDown = @Form1_Label1_MouseDown
this.Label1.OnMouseUp = @Form1_Label1_MouseUp
this.Label2.Parent = @this
this.Label2.Text = "Label2"
this.Label2.SetBounds(278,69,117,54)
this.Controls.Add(ControlType.Label, @this.Label1)
this.Controls.Add(ControlType.Label, @this.Label2)
Application.Forms.Add(ControlType.Form, @this)
end constructor
dim shared Form1 as Form1Type
' WINFBE_CODEGEN_END
''
'' Remove the following Application.Run code if it used elsewhere in your application.
Application.Run(Form1)
''
''
Function Form1_Label1_MouseDown( ByRef sender As wfxLabel, ByRef e As EventArgs ) As LRESULT
form1.label1.BackColor=colors.red
Function = 0
End Function
''
''
Function Form1_Label1_MouseUp( ByRef sender As wfxLabel, ByRef e As EventArgs ) As LRESULT
form1.label1.BackColor=colors.blue
Function = 0
End Function
Best wishes,
Ray
Yes, for some reason the DoubleClick on the Label is causing a GPF.
Quote from: rainheart311 on August 24, 2018, 11:39:05 PM
After version 1.7.3, there is such a problem: strange characters appear at the end of the Chinese menu and prompts, such as: 工具 (T) M, where M is redundant. Looking for the source code, it should be a problem with Mid, because it uses CWStr, so you need to use CWStr's MidChars function, I made such a modification, the display is normal:
'wData = Mid(wst, i+1)
wData = wst.MidChars(i+1)
In addition, thank you for your efforts and look forward to new progress.
I have changed the code in LoadLocalizationFile to the code you have suggested. Hopefully it results in the correct string being displayed for you.
You can also try wData = Mid(**wst, i+1). The Free Basic native string functions have always been problematic without the use of **.
Thank you, Paul.
I don't know why, use
'wData = Mid(wst, i+1)
wData = wst.MidChars(i+1)
After this change, there will be a situation of collapse during storage, and use
'wData = Mid(wst, i+1)
wData = Mid(**wst, i+1)
There is no problem with this change.
Hi Paul,
QuoteAlso, in MouseDown you should probably be setting the BackColorDown property rather than the BackColor property. Have you tried setting the properties via the PropertyList to see if gives you the result you are looking for when the mouse is pressed and released (by setting the properties in the Property List, BackColor, BackColorDown, etc).
Not on this version, but that worked OK in previous versions (I'd not tried the mousedown/mouseup as above in previous versions,iirc. ) I was just following up on my 'argument' that I didn't see the point of labels duplicating the functionality of buttons and was trying to test if both are capable of doing the same thing with more or less the same code.
Hi Ray,
You can use labels/statics as well as buttons to display images. But they behave differently.
Hi Wilko,
I've not got around to testing that advanced stuff. I'm getting problems just clicking on 'em.
Best wishes,
Ray
Hi Ray, thanks for testing the Label double clicking GPF. I looked further into it and it looks like was not handling the STN_DBLCLK message for the label (and then needing to dispatch it to the MouseDoubleClick handler). I made the change and it appears now that the Labels are working okay in the test code that you posted. I need to now look at the Button coloring you have spoken about.
Quote from: rainheart311 on August 24, 2018, 11:39:05 PM
After version 1.7.3, there is such a problem: strange characters appear at the end of the Chinese menu and prompts, such as: 工具 (T) M, where M is redundant. Looking for the source code, it should be a problem with Mid, because it uses CWStr, so you need to use CWStr's MidChars function, I made such a modification, the display is normal:
'wData = Mid(wst, i+1)
wData = wst.MidChars(i+1)
In addition, thank you for your efforts and look forward to new progress.
I have made a test with "工具".
DIM cws AS CWSTR = "工具"
AfxMsg MID(cws, 2)
AfxMsg MID(cws.wstr, 2)
AfxMsg MID(**cws, 2)
AfxMsg cws.MidChars(2)
Although the four variations return the same WSTRING pointer, MID(cws, 2) fails and the other three work. Why? I don't know. Maybe MID(cws, 2) if failing to recognize the returned pointer as a WSTRING pointer and interprets it as a ZSTRING pointer?
With LEFT and RIGHT, I solved the problem overloading them:
' ========================================================================================
PRIVATE FUNCTION Left OVERLOAD (BYREF cws AS CWSTR, BYVAL nChars AS INTEGER) AS CWSTR
RETURN LEFT(*cast(WSTRING PTR, cws.m_pBuffer), nChars)
END FUNCTION
' ========================================================================================
' ========================================================================================
PRIVATE FUNCTION Right OVERLOAD (BYREF cws AS CWSTR, BYVAL nChars AS INTEGER) AS CWSTR
RETURN RIGHT(*cast(WSTRING PTR, cws.m_pBuffer), nChars)
END FUNCTION
' ========================================================================================
But MID can't be overloaded, so we must use **.
Thanks for the info. I will update all mid code to use**
Jose, here is an interesting side effect I've discovered when I changed MID to use **. If MID returns a null string "" then it does not clear the CWSTR. If I do not use ** then it does clear. Here is test code that shows the problem:
#include once "Afx\CWSTR.inc"
dim as long i
dim as CWSTR wszMain, wszTemp
wszMain = "This is the main string="
wszTemp = "This is the temp string"
i = instr(wszMain, "=")
if i then
wszTemp = mid(**wszMain, i + 1)
'wszTemp = mid(wszMain, i + 1) ' <-- this works correctly
end if
? "i = "; i
? "wszTemp = "; wszTemp
?
? "wszTemp should be zero length, but it keeps the value 'This is the temp string'"
sleep
Easy to fix. I have moved the ckeck for a null pointer after the call to this.clear.
' ========================================================================================
PRIVATE OPERATOR CWstr.Let (BYREF pwszStr AS WSTRING PTR)
CWSTR_DP("CWSTR LET WSTRING PTR = " & .WSTR(pwszStr))
this.Clear
IF pwszStr = NULL THEN EXIT OPERATOR
this.Add(*pwszStr)
END OPERATOR
' ========================================================================================
Excellent, thanks José - works perfectly.
Hi Paul
Quote
Hi Ray, thanks for testing the Label double clicking GPF.
thanks for your thanks.
When you have the chance, have a look at the difference between the button and label text alignment. The label text behaves better, word wrapping nicely to multi lines for top line, maybe the centre line should word wrap both up and down lines, but the button text, even though there are more line choices, does no word wrapping (unless there's a preset I've not found).
Hi José,
There is currently no SetButtonBkColorHot setting so I noticed that when you paint the button that you use hBkBrushDown as the hot brush. This is what has led to Ray's observation earlier in this thread that the button back color is not colored correctly on MouseUp in his sample program.
I can see 2 options:
(1) Implement a Hot color for the button (I can easily add this within the WinFBE property list as well), or:
(2) Change the code around Line 959 to change the logic to use the hBkBrush instead of hBkBrushDown:
From:
DIM rc2 AS RECT = rcContent
.InflateRect @rc2, -1, -1 ' // To no overwrite the border
If iStateId = PBS_HOT And m_hBkBrushDown <> Null Then
.FillRect hDc, @rc2, m_hBkBrushDown
ELSE
IF m_hBkBrush THEN .FillRect hDc, @rc2, m_hBkBrush
END IF
To:
DIM rc2 AS RECT = rcContent
.InflateRect @rc2, -1, -1 ' // To no overwrite the border
IF m_hBkBrush THEN .FillRect hDc, @rc2, m_hBkBrush
If you chose to implement a Hot setting then the code could be like:
DIM rc2 AS RECT = rcContent
.InflateRect @rc2, -1, -1 ' // To no overwrite the border
IF m_hBkBrush THEN .FillRect hDc, @rc2, m_hBkBrush ' the default
If iStateId = PBS_HOT AndAlso m_hBkBrushHot <> Null Then
.FillRect hDc, @rc2, m_hBkBrushHot
END IF
What are your thoughts on this?
If you alreeady have tried it, give me your CxpButton.inc to incorporate it to the framework. If not, tell me which one of the two options you prefer. Personally, I don't care, since I'm not going to use colored buttons.
Quote from: José Roca on August 26, 2018, 03:48:00 PM
If you alreeady have tried it, give me your CxpButton.inc to incorporate it to the framework. If not, tell me which one of the two options you prefer. Personally, I don't care, since I'm not going to use colored buttons.
Ok, I am working the additions now and will post the modified file as soon as I am done. :)
Okay, the attached has the additions for the "Hot" brush color when mouse is over the button control.
Thanks. And if you want to add half a dozen colors more, feel free to do it :)
BTW see how easy is to make changes using soure code. If we were using libraries, we would have to build new libraries for both 32 and 64-bit, generate an import library, instruct people where to place them... Crazy!
:D Lol, yup, I agree 100%