Results 1 to 35 of 35

Thread: Form Caption

  1. #1

    Thread Starter
    Member
    Join Date
    May 2001
    Location
    Space...The Final Frontier
    Posts
    33

    Question Form Caption

    I am trying to make a form be maximized with no title bar, no min/max buttons, and no control box. Basically just the form covering the entire screen. I also want the form to show up on the taskbar with an icon and the name of the program. That way when you alt+tab you can choose the program.

    The problem is that if I try to give the form a caption then the title bar appears. If I don't give it a caption, then the taskbar shows a blank button.

    How can I make this work?

    I am open to any suggestions, even API if necessary...

    Thanks

  2. #2
    Addicted Member FOOBAR's Avatar
    Join Date
    Aug 2000
    Posts
    172
    make the form bordersytle none
    No Comment.

  3. #3
    Addicted Member FOOBAR's Avatar
    Join Date
    Aug 2000
    Posts
    172
    and also make the show in taskbar property set to ture
    No Comment.

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'Show the icon of a titleless form in taskbar tray 
    
    Private Declare Function SetWindowLong Lib "user32" _ 
    Alias "SetWindowLongA" (ByVal hwnd As Long, _ 
    ByVal nIndex As Long, ByVal dwNewLong As Long) _ 
    As Long 
    
    Private Const GWL_STYLE = (-16) 
    Private Const WS_SYSMENU = &H80000 
    
    '<<<<<< Form load >>>>>> 
    
    Private Sub Form_Load() 
    Call SetWindowLong(Me.hwnd, GWL_STYLE, WS_SYSMENU) 
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5

    Thread Starter
    Member
    Join Date
    May 2001
    Location
    Space...The Final Frontier
    Posts
    33
    Thanks,

    This seems to work, but it gives my form a control menu, which has the move and close choices enabled. I cannot have a control menu available on this form. Could this have something to do with the WS_SYSMENU constant? What should I change this to, so that I won't have a system menu??

    Also, what does the GWL_STYLE constant do?

    Thanks again

  6. #6

    Thread Starter
    Member
    Join Date
    May 2001
    Location
    Space...The Final Frontier
    Posts
    33
    Any Ideas?

  7. #7
    Hyperactive Member
    Join Date
    Jul 2001
    Location
    FL
    Posts
    258
    If you mean the menu that pops up when you right click the title bar or a minimized app, then set the forms Control Box property to False.

    I believe the WS_SYSMENU controls whether an application that is reudced to an icon has a System Menu or not.

  8. #8
    Addicted Member Dementia Freaks's Avatar
    Join Date
    Jun 2001
    Location
    Canada
    Posts
    132

    Cool THE EASIEST WAY....

    in the properties menu, set the controlbox to false, and set the borderstyle to none. Then, to make it cover the WHOLE screen, including the tasbar, insert this code:

    Code:
    Private Sub form_load()
    form1.height=screen.height
    form1.width=screen.width
    end sub
    I believe thats all you need. I cant help with having a captoin in the taskbar button without a title bar, sorry.
    Gray FOX: "Only a fool, trusts his life to a Weapon!"

    Bart Simpson: "Bart no like! Baaad medicene!"

    www.sling.to/dementia-freaks <<<---Goto my site!

    http://pub80.ezboard.com/bdementiafreaksforum <<<---Goto my forum!

    Thats it!

  9. #9

    Thread Starter
    Member
    Join Date
    May 2001
    Location
    Space...The Final Frontier
    Posts
    33
    I get the form to fill the screen by setting the form to maximize. I get rid of all of the title bar stuff, and the form displays fine, but when I look at the taskbar the button is blank. It seems that you have to have a caption on the form to have something other than a blank button on the taskbar. The problem is that if I put a caption on the form, it will show the title bar. How can I force the titlebar on the form to stay hidden?

    Thanks for any help...

  10. #10
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Brooklyn NY USA
    Posts
    1,258
    here you have got what you want.
    But you need to make a way to exit the program.
    and you need to compile it, it want work good in Debug.

  11. #11

    Thread Starter
    Member
    Join Date
    May 2001
    Location
    Space...The Final Frontier
    Posts
    33
    Thanks. I'll check it out and give it a try.

  12. #12
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Brooklyn NY USA
    Posts
    1,258
    Is it working for you?
    Please Post.

  13. #13

    Thread Starter
    Member
    Join Date
    May 2001
    Location
    Space...The Final Frontier
    Posts
    33

    Smile

    Sorry, but this doesn't really do anything that I need. The button on the taskbar does have the caption on it, but there is no icon for the program. Also, the form has a caption on it. This is what I have been trying to get rid of.

    Thanks for trying to help me.

  14. #14
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Brooklyn NY USA
    Posts
    1,258
    I realy dont know what you are talking about. Are you talking of the sample i posted. if yes check out this Exe its a compiled version of that code.

  15. #15
    Addicted Member
    Join Date
    Aug 2000
    Location
    Croatia
    Posts
    200
    OK, try this. It will show the form's caption in the task bar only...and as for the icon, dunno...


    Set the following form properties:

    BorderStyle - 0
    Caption - "Hello World"
    ShowInTaskbar - True

    And that's it!

  16. #16
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Brooklyn NY USA
    Posts
    1,258
    The same thing that i posted.

  17. #17
    Addicted Member
    Join Date
    Aug 2000
    Location
    Croatia
    Posts
    200
    Where? In attachment?

    FOOBAR posted the same thing also...
    Last edited by Arcom; Jul 29th, 2001 at 06:00 PM.

  18. #18

    Thread Starter
    Member
    Join Date
    May 2001
    Location
    Space...The Final Frontier
    Posts
    33
    I have done all of this, and I still can't get the icons to work properly. When I press ALT+Tab and get the task manager, the icon for my program is the windows logo. Also, the task bar button for the form has no icon.

    I don't know if it makes a difference, but this form is not the main form for my program. I hide the main from when I show this form, and I want this form to be full screen and act like it is now the main form. This means it should have a button with an icon, and show the proper icon on the task menu.

    Any ideas on how to do this?

    Thanks.

  19. #19
    Tygur
    Guest
    The solution to your problem should be simple enough. Set up the form to be maximized (Set the WindowState property to vbMaximized) and put this code in:
    VB Code:
    1. 'These are the API declarations
    2. 'Put this in the area above the rest of the form code (the General Declarations area)
    3. Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    4. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    5. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    6. Private Const GWL_STYLE = (-16)
    7. Private Const WS_BORDER = &H800000
    8. Private Const WS_MAXIMIZEBOX = &H10000
    9. Private Const WS_MINIMIZEBOX = &H20000
    10. Private Const WS_DLGFRAME = &H400000
    11. Private Const WS_THICKFRAME = &H40000
    12. Private Const SWP_FRAMECHANGED = &H20
    13. Private Const SWP_NOMOVE = &H2
    14. Private Const SWP_NOSIZE = &H1
    15. Private Const SWP_NOZORDER = &H4
    16.  
    17.  
    18.  
    19. 'This is the code to take out the border
    20. 'You probably want it in Form_Load
    21. Dim lStyle As Long
    22. lStyle = GetWindowLong(Me.hwnd, GWL_STYLE)
    23. lStyle = lStyle And Not (WS_BORDER Or WS_DLGFRAME Or WS_MAXIMIZEBOX Or WS_MINIMIZEBOX Or WS_THICKFRAME)
    24. Call SetWindowLong(Me.hwnd, GWL_STYLE, lStyle)
    25. SetWindowPos Me.hwnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED Or SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOZORDER

    The form will be maximized with no border so it takes the whole screen. When you look at the taskbar, the form will still have an icon and caption.

  20. #20
    Hyperactive Member FUBAR's Avatar
    Join Date
    Jan 2000
    Posts
    307
    u cant get a icon when u hit ctrl+alt+del but there must be some how to get it.... defualt is that windows icon

  21. #21
    New Member
    Join Date
    Jul 2001
    Location
    Vernon, BC, Canada
    Posts
    6

    ji

    He isnt talking about the CTRL-ALT-DEL menu, he means the Alt-Tab Task Manager
    tWiZtEr

  22. #22
    Tygur
    Guest
    Oh..
    oops
    I'll see what I can do, then..

  23. #23
    Tygur
    Guest
    Yeah, the icon does show in the Alt-Tab window. The program has to be running from an exe. You won't see the icon in the Alt-Tab window when you run the program from within the VB IDE. But if you compile it to an exe and run that, you see the icon just fine.

  24. #24
    Hyperactive Member FUBAR's Avatar
    Join Date
    Jan 2000
    Posts
    307
    oh ok, yea i meant alt+tab

  25. #25
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Brooklyn NY USA
    Posts
    1,258
    Yes Tygur that Api does the job.

  26. #26

    Thread Starter
    Member
    Join Date
    May 2001
    Location
    Space...The Final Frontier
    Posts
    33

    Red face

    Thank you Tygur.

    Now I may be getting a little picky here, but the form I am using this code on is not the main form for my program. When I bring up this form I hide the main form to prevent someone from Alt+Tabbing to the main form and messing around. I can't show the form modal, because I also show a small form with some other information. The user must be able to work with either form so it can't be modal.

    I guess I should state the problem before I go into detail, but for those of you still reading. When I use this code, the taskbar button doesn't have an icon. The icon shows up fine in the Alt+Tab thingy, but not on the taskbar. Is this possible to do or should I quit being so technical?

    I want the second form to appear to be the main form while the main form is hidden.

    Any ideas?

  27. #27
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    i had to make one of those for a "lock computer", cuz my little bro jumps for the comp when i leave it for a sec.


    In form properties, set the border style to normal, then double click on the title bar. it'll maximize the form. then set the border style to none. so it'll start up maximized (when you close VB then open the project again, it won't be maximized in the design view, but at runtime it will be)

    then to set the icon, click on the form and in the properties, choose your icon

    the in form_load(), put:
    VB Code:
    1. Me.Caption = "Caption"

    have it show up in the taskbar, and ur done.

    hope it helps,
    nabeel
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  28. #28

    Thread Starter
    Member
    Join Date
    May 2001
    Location
    Space...The Final Frontier
    Posts
    33
    Sorry, but that would give me the same problem I was having before with the title in the button, but no title bar.

    I think I need to use Tygur's API code, but there must be a switch to turn the icon on in the button.

    Thanks for trying to help me.

  29. #29
    Tygur
    Guest
    So the icon's not showing up in the taskbar button?

    Make sure ControlBox is True
    Also make sure the borderstyle is not None, Fixed Toolwindow, or Resizable Toolwindow.

    If the icon still isn't showing, let me know and I'll see what else could be preventing it.


    The form setup you're explaining confuses me, but if you want to show a form and have it always stay on top of another form while you can still use the other form, this works:
    Form2.Show , Form1

  30. #30
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    it's
    VB Code:
    1. me.icon.render(me.hdc,something....)

    im figuring that out

    to get a form to stay on top

    in module:
    VB Code:
    1. Const SWP_NOMOVE = 2
    2. Const SWP_NOSIZE = 1
    3. Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
    4. Const HWND_TOPMOST = -1
    5. Const HWND_NOTOPMOST = -2
    6.  
    7. Public Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As Long) As Long
    8. Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    9. Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
    10.     ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    11. Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long
    12.  
    13. Public Function SetTopMostWindow(hwnd As Long, Topmost As Boolean) As Long
    14.    If (Topmost) Then
    15.       SetTopMostWindow = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
    16.    Else
    17.       SetTopMostWindow = SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS)
    18.       SetTopMostWindow = False
    19.    End If
    20. End Function

    then to call it
    VB Code:
    1. 'on top:
    2. SetTopMostWindow Me.hwnd, True
    3.  
    4. 'not on top
    5. SetTopMostWindow Me.hwnd, False

    hope it helps

    -Nabeel
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  31. #31

    Thread Starter
    Member
    Join Date
    May 2001
    Location
    Space...The Final Frontier
    Posts
    33
    Tygur,

    I changed the controlbox and border on my form, and now the icon shows up, but if I hit ALT+SPACEBAR when my form is visible, I get a control menu with Move (disabled) and close. If I have controlbox False then the icon disappears.

    This would probably work, because there is no sign that there would be a control menu. The user would just have to guess and hit the ALT+SPACE.

    Any ideas on this one?

  32. #32
    Tygur
    Guest
    so you don't want the control menu?
    why not?

  33. #33

    Thread Starter
    Member
    Join Date
    May 2001
    Location
    Space...The Final Frontier
    Posts
    33
    I just think it looks kind of wierd for a control menu to pop up out of the top of the window when you hit ALT+SPACE. I suppose the ideal way for it to be would be to have the control menu only display off of the taskbar, and not from the window at all, but I don't think that is possible. I think I should be able to work with things the way they are now. Atleast there are no visible signs of the menu, and now all of the icons work properly.

    Thanks to all of you who helped me out with this problem.

  34. #34
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    did you try via API?


    VB Code:
    1. Private Declare Function SetWindowText Lib "user32" _
    2. Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
    3.  
    4.  
    5. dim cap as string
    6. cap = "the new caption"
    7. SetWindowText Me.hwnd, cap
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  35. #35
    Frenzied Member macai's Avatar
    Join Date
    Jul 2001
    Location
    Napanoch NY
    Posts
    1,228

    Cool CONTROL OFF NET

    hay, i found this control on the internet which literally puts an icon in the tray/takes it out with a simple setting. check it out
    Luke

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width