|
-
Feb 17th, 2007, 09:41 AM
#1
Thread Starter
Addicted Member
How to create VB form?
Hello,
Well, I'm searching for creating a standard VB form with only code and without make an instance of another form designed in VB development interface.
How can I do, please?
Thanks in advance.
-
Feb 17th, 2007, 09:48 AM
#2
Re: How to create VB form?
http://www.pscode.com/vb/scripts/Sho...67548&lngWId=1
you might want to take a look at the Sub_Main in the core module of this app
-
Feb 19th, 2007, 03:48 AM
#3
Thread Starter
Addicted Member
Re: How to create VB form?
Fundamentaly this is what I search : creating form, except I can't do that in an object module : when I used createwindowex api and getmodulehandle (with vbnullstring to identify the object module) to inform the first api module link, well, all VB developpment interface go down ! Why?
Do you also know a easy way to make form?
-
Feb 19th, 2007, 05:49 AM
#4
Re: How to create VB form?
why did it crash? because you did something wrong.
is there an easier way? yes, using the IDE - that's the point of using VB, it's RAD
-
Feb 19th, 2007, 07:35 AM
#5
Re: How to create VB form?
What, in your module, do you need to use that is related to your form?
-
Feb 19th, 2007, 09:10 AM
#6
Thread Starter
Addicted Member
Re: How to create VB form?
is there an easier way? yes, using the IDE - that's the point of using VB, it's RAD
Well I continue to search every solution while I haven't one that is satisfied me. I don't want to add another file for a form only to use it as a virgin one to support GDI+ operations. I want to create one dynamicaly. One solution is to make an instance of one existing, but I want a virgin one with no controls inside it (in reason of loading); I imagined that I could do a form object from VB librairies but it seems you can't do that easier than creating an instance of an common object !
I have some troubles of VB as soon as VB is reading the line with createwindowex api. I may did something wrong, I don't often use this particular api ; I only paste this part of code from a standard module to an object module. For me, I've respected all syntax. VB don't show debug dialog, and only Xp shows the standard stop application window.
I suppose that there's something wrong with getmodulehandle (in bold), and my feeling is that VB is overbooked or something like that in memory/handle operations... But how to run perfectly this code in my object module?
I post the function extracted from TheBigB's link :
VB Code:
Public Function WinCreate(winClassInfo As String, winAppInfo As String, ByRef winProcAddress As Long) As Boolean
Dim hh As Long
'store class name
winClassName = winClassInfo
'create class info
With winClass
.style = 0&
.lpfnwndproc = winProcAddress
.hInstance = App.hInstance
'default icon
.hIcon = LoadIconByNum(0&, IDI_APPLICATION)
'arrow-style mouse cursor
.hCursor = LoadCursorByNum(0&, IDC_ARROW)
.hbrBackground = COLOR_WINDOW
.lpszClassName = winClassName
.lpszMenuName = vbNullString
.cbClsextra = 0&
.cbWndExtra2 = 0&
End With
'register our class
winRegResult = RegisterClass(winClass)
'ok?
If Not winRegResult = 0 Then
'create window
WinHandle = CreateWindowEx(WS_EX_ACCEPTFILES, winClassName, winAppInfo, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0&, 0&, [B]GetModuleHandle(vbNullString)[/B], ByVal 0&)
If Not WinHandle = 0 Then
'show
'' ShowWindow winHandle, SW_SHOWNORMAL
'bring to front
'' SetForegroundWindow winHandle
'refresh
'' UpdateWindow winHandle
'done
WinCreate = True
Else
'create failed
WinCreate = False
End If
Else
'can not register class
WinCreate = False
End If
End Function
What, in your module, do you need to use that is related to your form?
Sorry I don't understand what you mean? Please could you reformulate?
Last edited by IsWorking; Feb 19th, 2007 at 09:16 AM.
-
Feb 19th, 2007, 09:15 AM
#7
Re: How to create VB form?
It is not clear to me why you need to do this.
 Originally Posted by IsWorking
Well, I'm searching for creating a standard VB form with only code and without make an instance of another form designed in VB development interface.
-
Feb 19th, 2007, 09:48 AM
#8
Thread Starter
Addicted Member
Re: How to create VB form?
I don't know if you have posted your message when I posted mine.
Two major reasons to search that : the challenge to perform it, and the wish to reduce the number of source files. I only need a visible form without title, buttons, border or other controls that it could have.
-
Feb 19th, 2007, 11:29 AM
#9
Re: How to create VB form?
One of the reasons the app crashed is that you can't run it in the IDE - there's no way to stop it other than using the IDE's stop button, which causes the IDE to crash since the window is subclassed. Put a command button on the form and use it to turn off the subclassing before destroying the window.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Feb 19th, 2007, 01:43 PM
#10
Re: How to create VB form?
 Originally Posted by IsWorking
I don't want to add another file for a form only to use it as a virgin one to support GDI+ operations
Why not?
-
Feb 19th, 2007, 02:02 PM
#11
Re: How to create VB form?
Create a formless form was my very first thread/post on VBF 
http://vbforums.com/showthread.php?t=67951
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 20th, 2007, 04:58 AM
#12
Thread Starter
Addicted Member
Re: How to create VB form?
I use getmodulehandle or instead of that app.hinstance, the end is the same : crashing !
 Originally Posted by Al42
One of the reasons the app crashed is that you can't run it in the IDE - there's no way to stop it other than using the IDE's stop button, which causes the IDE to crash since the window is subclassed. Put a command button on the form and use it to turn off the subclassing before destroying the window.
Well I don't known I'm subclassing something. I've thought that you can subclass only with callwindowproc api? How do I'm subclassing in my function please?
In fact, in the original application where the piece of code has been extracted, the program is running correctly under IDE! The problem is before to destroy my window, I need to create it ! I haven't the time to ask me if I click on vb stop button or on window close button ; in fact i can't seen anything like a form which appears on screen except crash dialog!
Create a formless form was my very first thread/post on VBF
How did you do? could you explain me why I don't manage myself? Have you written your code in a standard module or an object module?
-
Feb 20th, 2007, 11:06 AM
#13
Re: How to create VB form?
 Originally Posted by IsWorking
Well I don't known I'm subclassing something. I've thought that you can subclass only with callwindowproc api? How do I'm subclassing in my function please?
Right here
VB Code:
Public Function WinCreate(winClassInfo As String, winAppInfo As String, ByRef winProcAddress As Long) As Boolean
where you're creating the window with a proc. The IDE can't handle things correctly if there's a call to a procedure and you cause the program to close unexpectedly, making that procedure unavailable, but leaving something still hooked to it. If a WM_CLOSE message is sent to the window after it's been destroyed, the message has no procedure to handle it, so the IDE eventually crashes.
Last edited by Al42; Feb 20th, 2007 at 11:10 AM.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Feb 20th, 2007, 12:22 PM
#14
Re: How to create VB form?
The code is im my link I posted. Did you try it? Place it in a standard Module and set the sub main as the startup object.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 20th, 2007, 12:45 PM
#15
Re: How to create VB form?
@IsWorking: would you mind answering my question (if just purely for my curiosity) about why you need to create the form using API instead of just adding a blank one to your project. It's so much easier - and I can't see any (valid) reason why you wouldn't do it that way...
-
Feb 20th, 2007, 02:43 PM
#16
Re: How to create VB form?
I'm not 100% sure whether it is true, but check out the project in the link I've posted before. I'd bet it would render much faster in a API created form.
I don't want to add another file for a form only to use it as a virgin one to support GDI+ operations. I want to create one dynamicaly. One solution is to make an instance of one existing, but I want a virgin one with no controls inside it (in reason of loading); I imagined that I could do a form object from VB librairies but it seems you can't do that easier than creating an instance of an common object !
(you might have skipped this part)
-
Feb 22nd, 2007, 09:39 AM
#17
Thread Starter
Addicted Member
Re: How to create VB form?
 Originally Posted by Al42
Right here
VB Code:
Public Function WinCreate(winClassInfo As String, winAppInfo As String, ByRef winProcAddress As Long) As Boolean
where you're creating the window with a proc. The IDE can't handle things correctly if there's a call to a procedure and you cause the program to close unexpectedly, making that procedure unavailable, but leaving something still hooked to it. If a WM_CLOSE message is sent to the window after it's been destroyed, the message has no procedure to handle it, so the IDE eventually crashes.
I don't really understand :
I put this piece of code in an object module where a link in the initialise class sub call the function.
When I'm running the program with the VB step-by-step function, the program crashes when the createwindowex api call line is colored in yellow... I never see at this step any instructions to close the window(and I don't stop the program of course), I haven't yet build the first form!?
bushmobile, It could be very easier to create my form in the IDE but I really want to program it myself - it could not be so much impossible ! I don't want to add a file (and more a virgin form) in my source file collection.
I would be able to use one of which I've already designed in IDE and make instances of it to create dynamicaly others forms, but all of them have already controls !
Last edited by IsWorking; Feb 22nd, 2007 at 09:43 AM.
-
Feb 22nd, 2007, 10:44 AM
#18
Re: How to create VB form?
 Originally Posted by IsWorking
I don't really understand :
I put this piece of code in an object module where a link in the initialise class sub call the function.
When I'm running the program with the VB step-by-step function, the program crashes when the createwindowex api call line is colored in yellow.
The window is created with a handler that's subclassing the window. The IDE CAN NOT handle stepping through subclassing without special code (Bushmobile has an example in the code bank).
I never see at this step any instructions to close the window(and I don't stop the program of course), I haven't yet build the first form!?
You don't have to stop the program or close the window to cause a crash. If you create the window with a routine of yours handling the messages to that window (which is what you're doing), and the program stops (which is what single stepping is doing), the IDE crashes. Actually understandiong what's happening is a lot easier if you've worked in assembly and written TSRs or any other code that's hooked itself into a linked list. You can't do part of it and stop - all the code has to execute by itself to the point that everything is set up first - then you can step through it, which can't be done in the VB IDE if you're single stepping through creating the window.
I don't want to add a file (and more a virgin form) in my source file collection.
Just write all your code in your file form. You MUST have at least 2 files for any VB project.
I would be able to use one of which I've already designed in IDE and make instances of it to create dynamicaly others forms, but all of them have already controls !
You can do that with a form too.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Feb 22nd, 2007, 03:21 PM
#19
Re: How to create VB form?
 Originally Posted by IsWorking
bushmobile, It could be very easier to create my form in the IDE but I really want to program it myself - it could not be so much impossible ! I don't want to add a file (and more a virgin form) in my source file collection.
Yes I'm aware you said that, I am curious as to the reason why you don't want to do that. How do you think it will be deterimental to your project?
-
Feb 26th, 2007, 09:58 AM
#20
Thread Starter
Addicted Member
Re: How to create VB form?
You don't have to stop the program or close the window to cause a crash. If you create the window with a routine of yours handling the messages to that window (which is what you're doing), and the program stops (which is what single stepping is doing), the IDE crashes. Actually understandiong what's happening is a lot easier if you've worked in assembly and written TSRs or any other code that's hooked itself into a linked list. You can't do part of it and stop - all the code has to execute by itself to the point that everything is set up first - then you can step through it, which can't be done in the VB IDE if you're single stepping through creating the window.
I beg your pardon, but it's not very clear for me :
I've understood that my sub is handling a window but what is the "single stepping"?
What does mean TSR?
What could be a solution for this ?
I don't want to add forms and forms. My project is to make a splash screen with transparent png files and however keep my controls on the splash. Png need a form for layering but controls like labels disappear. Well, bushmobile's transparent form project in his codebank is a solution to manage to have png and controls. In conclusion I would need three forms (because transparent forms need already two, why?) only to have only one splash, one form for the user. it's a lot, isn't it? I found some pieces of code on internet and I was exciting to avoid me to multiply forms. But I can't perform that and I want to know why and how I can manage to do that?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|