Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > Starting, Exiting program and Image control


Reply
 
Thread Tools Display Modes
  #1  
Old 08-25-2004, 06:28 PM
waynespangler waynespangler is offline
Centurion
 
Join Date: Apr 2004
Location: West Virginia
Posts: 129
Default Starting, Exiting program and Image control


Hey guys,
I have downloaded vb express 2005 and I am having some problems.
I converted one of my vb6 programs and after a few changes I got it to mostly work (couple of problems).
1. When I run the program (IDE or compiled) the button shows up in the task bar and if down, as it should be, but the form is not showing. By pressing the button to minimize it and again to restore it then it shows. I have tried the Me.Show() but that doesn't work. Also ending the program the form goes away but the button is still there. Pressing it to minimize it and pressing it to restore it the form comes back. I tried using Application.Exit() but does no good.
2. I have an image that shows in the design window but when the program is run it is not showing. It must be something simple but I can't figure it out.
I have programed with vb since version 1 but I think I have my work cut out for me in vb net.
Thanks in avdance for any help,
Wayne
__________________
Wayne
2 quotes by Henry Ford I like:
"Nothing is particularly hard if you divide it into small jobs."
"Thinking is the hardest work there is, which is probably the reason why so few engage in it."
Reply With Quote
  #2  
Old 08-25-2004, 07:13 PM
blindreaper666's Avatar
blindreaper666 blindreaper666 is offline
Junior Contributor
 
Join Date: Aug 2004
Posts: 317
Default

Quote:
Originally Posted by waynespangler
Hey guys,
I have downloaded vb express 2005 and I am having some problems.
I converted one of my vb6 programs and after a few changes I got it to mostly work (couple of problems).
1. When I run the program (IDE or compiled) the button shows up in the task bar and if down, as it should be, but the form is not showing. By pressing the button to minimize it and again to restore it then it shows. I have tried the Me.Show() but that doesn't work. Also ending the program the form goes away but the button is still there. Pressing it to minimize it and pressing it to restore it the form comes back. I tried using Application.Exit() but does no good.
2. I have an image that shows in the design window but when the program is run it is not showing. It must be something simple but I can't figure it out.
I have programed with vb since version 1 but I think I have my work cut out for me in vb net.
Thanks in avdance for any help,
Wayne

try me.showdialog() and me.close() but I haven't used any images in my programs, and I somewhat new to .net so I can't help with the image. Mabey if you post your source code, I can figure it out because It was also hard for me to convert from vb6 to .net but I got the hang of most of the little changes
Reply With Quote
  #3  
Old 08-25-2004, 07:19 PM
Iceplug's Avatar
Iceplug Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: California, USA
Posts: 16,583
Default

I would suggest you start by programming solely in .NET before trying to convert projects.
(And since there's no code, we can only guess)
Try adding a new "image" to the form in place of the old "image". Is that a picturebox?
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #4  
Old 08-25-2004, 08:01 PM
waynespangler waynespangler is offline
Centurion
 
Join Date: Apr 2004
Location: West Virginia
Posts: 129
Default

My code for ending the program:
Code:
Public Sub EndProgram()
     Dim frm As System.Windows.Forms.Form
     For Each frm In My.Application.OpenForms
	frm.Close()
     Next frm
     Application.Exit()
End Sub
My form load is:
Code:
    Private Sub frmMain_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
        Dim buffer As String
        Me.Show()
        Image1.Width = VB6.TwipsToPixelsX(VB6.PixelsToTwipsX(Me.ClientRectangle.Width) - 2)
        'check if new installation
        If Dir(My.Application.CurrentDirectory & "\Leagues.dat") > "" Then
            'if not then open the leaques data and get all league names
            FileOpen(1, My.Application.CurrentDirectory & "\leagues.dat", OpenMode.Input)
            While Not EOF(1)
                buffer = LineInput(1)
                If Trim(buffer) <> "" Then
                    Combo1.Items.Add(buffer)
                End If
            End While
            FileClose()
        End If
        'ListCount is -1 so if not new installation then set the listcount to first item
        If Combo1.Items.Count > 0 Then
            Combo1.SelectedIndex = 0
        End If
    End Sub
In the past I have learned more by converting my old programs. I can see what changes have been made and change my mind set. I do plan on getting a book and surfing the internet for tutorials but I got the program and wanted to use it right away.
Thanks,
Wayne
__________________
Wayne
2 quotes by Henry Ford I like:
"Nothing is particularly hard if you divide it into small jobs."
"Thinking is the hardest work there is, which is probably the reason why so few engage in it."
Reply With Quote
  #5  
Old 08-25-2004, 08:15 PM
Iceplug's Avatar
Iceplug Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: California, USA
Posts: 16,583
Default

The tool doesn't convert the function calls to .NET standard.
For example:
Trim is not a .NET function but a VB backwards compatibility, and
Trim(S) is equivalent to S.Trim(), so there's not much need to use Trim()... similarly, I doubt you really need to convert pixels to twips and back.
FileOpen, LineInput, and FileClose are all VB backwards, and you have the StreamReader object which does the same thing except works for all .NET languages.

If you want to keep using the old VB functions, go right ahead. Just remember that they don't work in other .NET languages (it is depressing that they aren't automatically converted, though perhaps they don't want you to go to other languages )

Anyway what's the "image"? You still haven't said what it is.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #6  
Old 08-25-2004, 08:37 PM
waynespangler waynespangler is offline
Centurion
 
Join Date: Apr 2004
Location: West Virginia
Posts: 129
Default

Thanks for your reply. I guess I have a lot to learn. I would have thought that the conversion would have put in the "modern" code.
I guess I use Image to include all pictures but it is listed in the properties as:
System.Windows.Forms.Picturebox.
In the properties:
SizeMode = StretchImage
Image = System.Drawing.Bitmap
InitalImage = System.Drawing.Bitmap
WaitOnLoad = True
Enabled = True
Visable = True
Locked = True
Modifiers = Friend
Anchor = Top Left
AutoRelocate = True
Dock = Top

Those seem to me to be the ones that may be effecting it.
Thanks I do appreciate your time and patience.
__________________
Wayne
2 quotes by Henry Ford I like:
"Nothing is particularly hard if you divide it into small jobs."
"Thinking is the hardest work there is, which is probably the reason why so few engage in it."
Reply With Quote
  #7  
Old 08-25-2004, 08:41 PM
Iceplug's Avatar
Iceplug Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: California, USA
Posts: 16,583
Default

Have you tried putting a new picturebox on the form in its place?
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #8  
Old 08-25-2004, 08:53 PM
waynespangler waynespangler is offline
Centurion
 
Join Date: Apr 2004
Location: West Virginia
Posts: 129
Default

I deleted the old picturebox and put in a new one. I still doesn't show. I am using some api's to hide the title bar. It might have something to do with it. I am going to comment out that code and see if that is the problem.
Thanks
__________________
Wayne
2 quotes by Henry Ford I like:
"Nothing is particularly hard if you divide it into small jobs."
"Thinking is the hardest work there is, which is probably the reason why so few engage in it."
Reply With Quote
  #9  
Old 08-25-2004, 09:06 PM
waynespangler waynespangler is offline
Centurion
 
Join Date: Apr 2004
Location: West Virginia
Posts: 129
Default

It was the api code. Once I got rid of it then all went right. Prehaps you can help me on this. I need the title bar so that the info will show up on the task bar. I used the following code to hide the title bar.
Code:
            'If I do away with the titlebar then nothing shows up on the task bar. I also don't have
            'access to the minimize or restore buttons or the exit button(X). So I  have to keep the
            'titlebar but make it invisible.
            'First make sure the form is not being minimized otherwise we get an error
            If WindowState = System.Windows.Forms.FormWindowState.Minimized Then
                FormShow = True
                frmLeague.Visible = False
                Exit Sub
            End If
            'Find the border width which is the difference of the width and the scalewidth divided by 2. P.S. this I had to change due to .NET            Border = (VB6.PixelsToTwipsX(Me.Width) - VB6.PixelsToTwipsX(Me.ClientRectangle.Width)) / 2
            'Now to get the title bar height subtract the scaleheight and the border from the heightB] P.S. this I had to change due to .NET[/B] 
            TitleHeight = VB6.PixelsToTwipsY(Me.Height) - VB6.PixelsToTwipsY(Me.ClientRectangle.Height) - Border
            'Convert the title height to pixels and subtract the border from the title bar heightB] P.S. this I had to change due to .NET[/B] 
            TitleHeight = TitleHeight - Border
            '**************************************************************************************************
            'THE FOLLOWING CODE WAS PICKED UP FROM THE INTERNET AND IS MOSTLY
            'NOT MINE. I FORGOT WHERE IT CAME FROM.
            '***************************************************************************************************
            wid = VB6.PixelsToTwipsX(Width)
            hgt = VB6.PixelsToTwipsY(Height)
            'Create the outer region which is the full form
            outer_rgn = CreateRectRgn(0, 0, wid, hgt)
            'Create the inter region which is the title bar
            inner_rgn = CreateRectRgn(0, 0, wid, TitleHeight)
            'Create a blank region and combine the two regions subtracting the inter from the outer
            combined_rgn = CreateRectRgn(0, 0, 0, 0)
            CombineRgn(combined_rgn, outer_rgn, inner_rgn, RGN_DIFF)
            'Now set the window to the new display
            SetWindowRgn(Handle.ToInt32, combined_rgn, True)
            'Delete all the regions created
            DeleteObject(combined_rgn)
            DeleteObject(inner_rgn)
            DeleteObject(outer_rgn)
Is there a better way to do this?
Thank You,
__________________
Wayne
2 quotes by Henry Ford I like:
"Nothing is particularly hard if you divide it into small jobs."
"Thinking is the hardest work there is, which is probably the reason why so few engage in it."
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->