Manually changing location of a Form in Minimized State / Form.ShowInTaskbar=False

Behrooz

Member
Joined
Feb 8, 2007
Messages
15
Programming Experience
5-10
I need help on a problem as bellow:

I have Form1 that the Form1.ShowInTaskbar property set to False,
After click on the minimized box when the form is in normal state it goes down and locate in the bottom - Left of my screen (excactly above the windows start button). I Want to change the location of this little title-bar. I have written the code bellow in Form1.move event but it is working just After I click on the maximized button and this will change my form-location at the normal window state:
Me.Location = New Point(598, 850)

note: I have not any restore button in my form so my form is not sizable

Pls F1 me . . . !! :confused: :( :confused::confused:
 
There is not any minimized Form Event

thanks

but

There Is not any Minimized Form Event in VB.NET 2005, I am so sorry about that. :(

Thanks for Reply
 
There is a Resize event.
 
Resize Event can not Help

I`ve wrote this code in resize event but it can not help me because, I have minimized my form and it has been minimizd in it`s default location as I told:(above the windows start button) and when I clicked on the maximize button the form went to the location which I write below::mad: :mad: :mad:

If CStr(Me.WindowState) = 1 Then
Me.DesktopLocation = New Point(139, 691)
End If

But I want to Set the location of exactly the minimized form.
 
I got this working with Win32 function SetWindowPos, don't know if it's fully correct or there exist better ways..
VB.NET:
    Declare Function SetWindowPos Lib "user32.dll" ( _
  ByVal hwnd As Int32, _
  ByVal hWndInsertAfter As Int32, _
  ByVal x As Int32, _
  ByVal y As Int32, _
  ByVal cx As Int32, _
  ByVal cy As Int32, _
  ByVal wFlags As Int32) As Int32
 
    Const SWP_NOSIZE As Int32 = &H1
 
    Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) _
    Handles Me.Resize
        If Me.WindowState = FormWindowState.Minimized Then
            SetWindowPos(Me.Handle.ToInt32, 0, 598, 850, 0, 0, SWP_NOSIZE)
        End If
    End Sub
 
It appears that nothing that would move a form, can be used when the form is minimized, in VBN at least.. I did this:

VB.NET:
        If Me.WindowState = FormWindowState.Minimized Then
            Me.Visible = False
            Me.WindowState = FormWindowState.Normal
            Me.Location = New Point(100, 100)
            Me.WindowState = FormWindowState.Minimized
            Me.Visible = True
        End If
    End Sub

but it screwed up the position upon restore, and the restored version appeared near the start menu, flattened like the minimized form.

Interestingly, Resize fires twice in this case.. Once when you restore the form and it reverts to full size, then again, when it jumps to sitting above the start button, (normal windowstate, not minimized)

Nuisance..


Maybe its easier to re-think this part of your app?
 
re:thanks but it does`nt work properly

Thanks both of you
But Dear John:

Your code just hide my form so I had not any reach to it until I Closed my application!!!!!!!!!

and Dear CJard:

Your code makes my form always in minimized state. and I could`nt maximized it ever.

Because I have set the ShowInTaskbar property of my form to False and my form is not Sizable, I just want to change the little minimized form which is been minimized and loacated a little above windows start button . . .

U know when it get to minimized state, I have chance to change its location by mouse draging the minimized Form, I`ve been confused : How its not possible to change its location by code?:mad:
 
Your code just hide my form so I had not any reach to it until I Closed my application!!!!!!!!!
No it didn't, not when I ran the code. I does exactly what you ask for; to change the location of the minimized and non-trayed mini-titlebar-form on desktop. If it appeared hidden for you, maybe you should place it another location? how about location (0,0) ? (topleft)
 
Thanks both of you
Your code makes my form always in minimized state. and I could`nt maximized it ever.

I told you my code was broken.. Sorry you found it to be broken.
Tell me your paypal address so i can give you a refund.. ;)




How its not possible to change its location by code?:mad:
I think because VBN does some trickery.. Bad mojo! :( See John's API call instead
 
re: For Cjard

Oh yeah thanks . . .

I am learning, and I respect all u great people who are helping guys like me. You will exactly be in the paradise, I wish we could work with a great P.C in there and then asking question about VB (maybe .ParadiizeNET) on big Forums. :D ;)
 
Back
Top