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.
Printable View
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.
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
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?
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
What, in your module, do you need to use that is related to your form?
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 !Quote:
is there an easier way? yes, using the IDE - that's the point of using VB, it's RAD
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
Sorry I don't understand what you mean? Please could you reformulate?Quote:
What, in your module, do you need to use that is related to your form?
It is not clear to me why you need to do this.Quote:
Originally Posted by IsWorking
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.
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.
Why not?Quote:
Originally Posted by IsWorking
Create a formless form was my very first thread/post on VBF :D
http://vbforums.com/showthread.php?t=67951
I use getmodulehandle or instead of that app.hinstance, the end is the same : crashing !
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?Quote:
Originally Posted by Al42
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!
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?Quote:
Create a formless form was my very first thread/post on VBF
Right hereQuote:
Originally Posted by IsWorking
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.VB Code:
Public Function WinCreate(winClassInfo As String, winAppInfo As String, ByRef winProcAddress As Long) As Boolean
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.
@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...
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.
(you might have skipped this part)Quote:
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 don't really understand :Quote:
Originally Posted by Al42
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 !
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).Quote:
Originally Posted by IsWorking
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.Quote:
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!?
Just write all your code in your file form. You MUST have at least 2 files for any VB project.Quote:
I don't want to add a file (and more a virgin form) in my source file collection.
You can do that with a form too.Quote:
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 !
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?Quote:
Originally Posted by IsWorking
I beg your pardon, but it's not very clear for me :Quote:
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'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?