I have a VB project that has a Borderless form. I'm trying to update its caption while it has been minimized, but I can't.
The code in the "Form" is is follows: - Public myCounter As Integer
-
-
Private Sub cmdExit_Click()
-
End
-
End Sub
-
-
Private Sub cmdMinimize_Click()
-
Me.WindowState = vbMinimized
-
End Sub
-
-
Private Sub myTimer_Timer()
-
myCounter = myCounter + 1
-
Me.Caption = myCounter
-
End Sub
When I click on its "Minimized Caption Bar" or when it Loses Focus, its caption will be updated with the code in the Timer. But this is not what I'm looking for. I'd like to have it updated with the code in the Timer without gaining or losing focus.
I tested other ways. For example, I changed the code in "Sub myTimer_Timer()" to this: - Private Sub myTimer_Timer()
-
myCounter = myCounter + 1
-
Me.Show
-
Me.Caption = myCounter
-
End Sub
or even to this: - Private Sub myTimer_Timer()
-
myCounter = myCounter + 1
-
Me.SetFocus
-
Me.Caption = myCounter
-
End Sub
Using these two tricks, I can have it updated according to the Interval set for the Timer. But the problem is that its "Minmized Caption Bar" blinks and is rather annoying.
How can I have it updated "Without Blinking"?
Thank you for your help.
You can only change the caption if border is shown.
So if You minimize, set the border ON.
When You set the form back (resize), set the border back OFF. - Public myCounter As Integer
-
-
Private Sub cmdExit_Click()
-
End
-
End Sub
-
-
Private Sub cmdMinimize_Click()
-
With Me
-
.WindowState = vbMinimized
-
.ZOrder
-
.BorderStyle = vbFixedSingle
-
End With
-
End Sub
-
-
Private Sub Form_Resize()
-
Me.BorderStyle = vbBSNone
-
End Sub
-
-
Private Sub myTimer_Timer()
-
myCounter = myCounter + 1
-
Me.Caption = myCounter
-
End Sub
9 2320
You can only change the caption if border is shown.
So if You minimize, set the border ON.
When You set the form back (resize), set the border back OFF. - Public myCounter As Integer
-
-
Private Sub cmdExit_Click()
-
End
-
End Sub
-
-
Private Sub cmdMinimize_Click()
-
With Me
-
.WindowState = vbMinimized
-
.ZOrder
-
.BorderStyle = vbFixedSingle
-
End With
-
End Sub
-
-
Private Sub Form_Resize()
-
Me.BorderStyle = vbBSNone
-
End Sub
-
-
Private Sub myTimer_Timer()
-
myCounter = myCounter + 1
-
Me.Caption = myCounter
-
End Sub
Thank you, Mr. Guido Geurs,
You're a great expert. I applied your code to the project. Attached to this post, you'll find the "Modified Project". But, something is wrong.
When I minimize the form, its caption will be updated as I needed. But, something really odd happens. Every time, after minimizing the form, if you double click on the minimized form to restore it, it will be restored, but, unfortunately, it shrinks and gets smaller.
If you minimize and restore the form several times, you won't see anything when restoring the form. The form vanishes.
I made some changes to the code to fix this bug. Here's the new code: - Public myCounter As Integer
-
Public myFormWidth As Long
-
Public myFormheight As Long
-
-
Private Sub cmdExit_Click()
-
End
-
End Sub
-
-
Private Sub cmdMinimize_Click()
-
With Me
-
.WindowState = vbMinimized
-
.ZOrder
-
.BorderStyle = vbFixedSingle
-
End With
-
End Sub
-
-
Private Sub Form_Load()
-
myFormWidth = Me.Width
-
myFormheight = Me.Height
-
End Sub
-
-
Private Sub Form_Paint()
-
Me.Width = myFormWidth
-
Me.Height = myFormheight
-
End Sub
-
-
Private Sub Form_Resize()
-
Me.BorderStyle = vbBSNone
-
End Sub
-
-
Private Sub myTimer_Timer()
-
myCounter = myCounter + 1
-
Me.Caption = myCounter
-
End Sub
Thanks to your help, nearly 90% of the job has been done.
There is only one problem. If you minimize the form, and then, double click on the "Minimized Caption Bar" to restore the form, at first, the Caption of the Form is visible and after a very very short time, it changes to nothing and becomes invisible.
Is there any method to fix this bug? I mean, when you double click on the "Minimized Caption Bar" to restore the form, prevent the Caption of the Form to be visible even for a very very short time?
Thank you for your great help.
With the code= - Private Sub cmdMinimize_Click()
-
With Me
-
.WindowState = vbMinimized
-
.ZOrder
-
.BorderStyle = vbFixedSingle
-
End With
-
End Sub
-
-
Private Sub Form_Resize()
-
Me.BorderStyle = vbBSNone
-
End Sub
When The code does a Minimize then it takes (remembers) the size of the "No border" and set then the border "FixedSingle" with the size of "No Border".
When it Resizes, the borders will be the original min borderwidth and the titelbar !
With the code: - Public myCounter As Integer
-
-
Private Sub cmdExit_Click()
-
End
-
End Sub
-
-
Private Sub cmdMinimize_Click()
-
With Me
-
.BorderStyle = vbFixedSingle
-
.WindowState = vbMinimized
-
.ZOrder
-
End With
-
End Sub
-
-
Private Sub Form_Resize()
-
Me.BorderStyle = vbBSNone
-
Me.ZOrder
-
End Sub
-
-
Private Sub myTimer_Timer()
-
myCounter = myCounter + 1
-
Me.Caption = myCounter
-
End Sub
-
It's OK : it sets first the frame back and then minimizes.
I changed the following parts of the code using your suggested code: - Private Sub cmdMinimize_Click()
-
With Me
-
.BorderStyle = vbFixedSingle
-
.WindowState = vbMinimized
-
.ZOrder
-
End With
-
End Sub
-
-
Private Sub Form_Resize()
-
Me.BorderStyle = vbBSNone
-
Me.ZOrder
-
End Sub
But, this way, the "Minimized Caption Bar" doesn't get updated. It only gets updated when losing and gaining focus.
You're a great expert. Thank you a million times for your kind help.
I'm so happy to see intelligent experts like you in Bytes.com (a really valuable and excellent website for programmers).
Best wishes for you.
Sorry for my inattention but I think this is finally the one: - Dim ORGWIDTH As Long
-
Dim ORGHEIGHT As Long
-
Public myCounter As Integer
-
-
Private Sub cmdExit_Click()
-
End
-
End Sub
-
-
Private Sub cmdMinimize_Click()
-
With Me
-
.WindowState = vbMinimized
-
.ZOrder
-
End With
-
End Sub
-
-
Private Sub Form_Load()
-
With Me
-
ORGWIDTH = .Width
-
ORGHEIGHT = .Height
-
End With
-
End Sub
-
-
Private Sub Form_Resize()
-
With Me
-
If .WindowState = vbMinimized Then
-
.BorderStyle = vbFixedSingle
-
Else
-
.BorderStyle = vbBSNone
-
.Width = ORGWIDTH
-
.Height = ORGHEIGHT
-
End If
-
.ZOrder
-
End With
-
End Sub
-
-
Private Sub myTimer_Timer()
-
myCounter = myCounter + 1
-
Me.Caption = myCounter
-
End Sub
Thank you, sir.
You're so kind and attentive to this matter. I appreciate your help.
This is the code with your modifications. But, still the problem is there. When you "Double Click" on the "Minimized Caption Bar", it will be resized to the "Original Form Size", but at first, the Caption of the Form is visible. After a very short time, it disappears. This doesn't make any problems, though.
Again, thank you for your attention.
After a few trays I think I have found the solution for resetting the border immediately ofter maximize: Only the code "Me.Caption = Me.Caption" will rebuild the border.
Not .Refresh, ... ore anything else!
So the code must be= - Dim ORGWIDTH As Long
-
Dim ORGHEIGHT As Long
-
Public myCounter As Integer
-
-
Private Sub Form_Load()
-
With Me
-
ORGWIDTH = .Width
-
ORGHEIGHT = .Height
-
End With
-
End Sub
-
-
Private Sub Form_Resize()
-
With Me
-
If .WindowState = vbMinimized Then
-
.BorderStyle = vbFixedSingle
-
Else
-
.BorderStyle = vbBSNone
-
.Caption = .Caption
-
.Width = ORGWIDTH
-
.Height = ORGHEIGHT
-
End If
-
.ZOrder
-
End With
-
End Sub
-
-
Private Sub cmdExit_Click()
-
End
-
End Sub
-
-
Private Sub cmdMinimize_Click()
-
With Me
-
.WindowState = vbMinimized
-
.ZOrder
-
End With
-
End Sub
-
-
Private Sub myTimer_Timer()
-
myCounter = myCounter + 1
-
Me.Caption = myCounter
-
End Sub
Thank you, Mr. Guido Geurs,
Honestly, I have to say that you're a really great and talented Solution Developer. I can't believe that it has been solved.
Using your incredible method to solve this problem, I added one line to your final solution.
Now, thanks to your great solution, when I click on the "Minimized Caption Bar" to restore the program to its Original Size, the problem has been fixed. But, when I click on the Minimize Button to Minimize the program, a problem still exists. I mean, if you press the Minimize Button, the program will be minimized, but for a very very short time, you can see the Minimized Caption Bar has "Windows Classic Style", even if you use "Windows XP Style" theme on your computer.
This is a modification of Sub Form_Resize(): - Private Sub Form_Resize()
-
With Me
-
If .WindowState = vbMinimized Then
-
.BorderStyle = vbFixedSingle
-
.Caption = .Caption '==> This line has been added!
-
Else
-
.BorderStyle = vbBSNone
-
.Caption = .Caption
-
.Width = ORGWIDTH
-
.Height = ORGHEIGHT
-
End If
-
.ZOrder
-
End With
-
End Sub
Actually, I was disappointed and I thought it wasn't possible to solve this problem. But you made it possible.
You did a great job. Thank you very much, my dear friend.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: plank |
last post by:
Hey,
I am new to C# and am trying to resize a borderless form with the
mouse is pressed and dragged within a specified rectangle coordinates
on the form.
Any help would be much appreciated!
...
|
by: Nikki |
last post by:
Hi,
I m developing a window's application in c#. As due to non-rectangular
forms, i m using borderless form. Now i need help in how to provide
user with resizing facality of the form using mouse....
|
by: notregister |
last post by:
hi,
in VB6 i can change the caption of the form by using
frmMain.Caption = "ABC"
how do i change it in .NET??
the text i want to change is found at the form1's properties > Appearance>
text
|
by: David Gouge |
last post by:
Hi All,
I have a borderless form that i can drag around fine when dragging
anywhere on the form by using the following code:
protected override void WndProc(ref Message m)
{
const int...
|
by: SeanR |
last post by:
Hi,
I wasn't happy with the customisability of the standard Windows form,
so I decided to implement my own. Basically what I did was extend a
borderless form and add my own borders and caption...
|
by: Rick |
last post by:
I know I seen this before but IO cannot find it. How to you drag a
borderless form in Vb.net 2005
|
by: James Arnold |
last post by:
I currently have a borderless form, which I am subclassing to allow
dragging & dropping:
Protected Overrides Sub WndProc(ByRef m As Message)
Select Case m.Msg
Case 132 'Click & Drag Form...
|
by: sierra7 |
last post by:
Hi
I have been writing Access applications for some years now and have moved away from from the 'Switchboard' type of opening form to using a menubar accross the top of the screen and borderless...
|
by: plevintampabay |
last post by:
I have a borderless form in C#.
The form has an icon specified in its properties and I also have the same icon specified for the project in the project properties.
When I had a border on the...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |