LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PopUpMenu's "work", but crash on exit when compiled.

I've been fooling around with PopUp menu's using the USER32 DLL. One question I still have is should I destroy all submenus, or will destroying the top popup destroy all the submenus. It doesn't seem to make a difference.

Also, when I compiled a demo program, I noticed the USER32.DLL showed up in my data folder. The program seems to work, until I close the window, when I get a bomb window titled "Quincy Fatal Error". The text in the window is

Could not attach to the application
Windows Error Code = The parameter is incorrect.

The program seems to work fine, I can start and restart it all I want. It's when I click on the CloseWindow X in the upper RHCorner that I get this error. I've looked at some other
code on the forums and it looks like everything is OK.

Has anyone else seen this behavior, or could steer me in the right direction?

Thanks, Bob
0 Kudos
Message 1 of 8
(3,295 Views)
Here's some more info.

If I actually remove the DLL calls, the program does not bomb on exit. If I comment out all the DLL calls, (never calling any of them) but leave the references in, the program bombs on exit. Does this have something to do with the fact that the compiler seems to be making copies of DLL's in the System32 folder?

Bob
0 Kudos
Message 2 of 8
(3,295 Views)
> If I actually remove the DLL calls, the program does not bomb on exit.
> If I comment out all the DLL calls, (never calling any of them) but
> leave the references in, the program bombs on exit. Does this have
> something to do with the fact that the compiler seems to be making
> copies of DLL's in the System32 folder?
>

This likely has more to do with the fact that the DLL's DLLMain function
will get called when loaded and unloaded from memory, even if no other
functions are called from LV or any other program. If you have the
source code to the DLL, inspect the DLLMain source to see if it could be
the culprit.

Greg McKaskle
0 Kudos
Message 3 of 8
(3,294 Views)
Hi,

Is this the popupmenu dll that I made?

I missed the discusion, but if it is, I'll try to compile it myself.

Regards,

Wiebe.


"INTP56" wrote in message
news:50650000000500000090DE0000-1042324653000@exchange.ni.com...
> Here's some more info.
>
> If I actually remove the DLL calls, the program does not bomb on exit.
> If I comment out all the DLL calls, (never calling any of them) but
> leave the references in, the program bombs on exit. Does this have
> something to do with the fact that the compiler seems to be making
> copies of DLL's in the System32 folder?
>
> Bob
0 Kudos
Message 4 of 8
(3,294 Views)
Just for the heck of it, I deleted the DLL's the compiler made (USER32.DLL & KERNEL32.DLL) and put in the data folder. When I run the compiled program, a window appears briefly (it looks like a search window) and then the program runs. But now it doesn't bomb on exit.

I'm still confused about whether I need to delete SubMenus. I read this in a book I have refering to DestroyMenu, "Note that menus that are part of another menu or assigned directly to a window are automatically destroyed when the window is destroyed." But if the program is left running and I only delete the parent, will I have a lot of orphaned submenus lurking in memory until the app quits? Or will destroying the parent menu destroy all descendants?

Of course, I should have searched for
what other's had done with PopUpMenus BEFORE I started on my own, rather than AFTER I started having problems. Oh well, maybe I'll learn.

Also, I found that Quincy is a debugger that installed when Lotus Notes is installed. This turned out to be a Red Herring, since that had nothing to do with anything, other then dropping into a low-level debugger when a fatal error occured.

Bob
0 Kudos
Message 5 of 8
(3,294 Views)
Wiebe,

I did see a reference to a PopUpMenu Toolkit you created last year, but it wasn't posted on the BB, it seemed you sent it directly to several parties.

BTW, Do you destroy only the parent popupmenu, or all the submenus too?

Bob
0 Kudos
Message 6 of 8
(3,294 Views)
Bob,

If I recall correctly, I delete the references to the sub menus right after
the AppendMenu function (which is superseeded by InsertMenuItem, by the
way).

The AppendMenu function copies the menu, and deletes it's own reference when
the root is deleted. But the original reference must be destroyed. It is
most practical to do this right after the append, so the reference does not
need to be buffered.

Coincidently, my toolkit also had troubles after compiling it to an
executable. I created some LVDChild windows, but this failed with
executeables, because then the LVDChild is an unregister class... Also,
there where some issues with a splashscreen that appears at start. Some
resources where not closed, and the dll could only be loa
ded once (e.g. LV
had to be closed completely to be able to reload the example). This is all
resolved now. So thank you for that!

And yes, I only send it to some interrested people. I don't post it here,
mostly because newsgroups are not to be used to post binairies. Also,
messages with attachments don't show up in outlook (at least with my
config...) so I can't see any reactions to my own post.

Regards,

Wiebe.



"INTP56" wrote in message
news:506500000005000000C6DE0000-1042324653000@exchange.ni.com...
> Wiebe,
>
> I did see a reference to a PopUpMenu Toolkit you created last year,
> but it wasn't posted on the BB, it seemed you sent it directly to
> several parties.
>
> BTW, Do you destroy only the parent popupmenu, or all the submenus
> too?
>
> Bob
0 Kudos
Message 7 of 8
(3,294 Views)
Wiebe,

I'm glad I was able to help you, even if I didn't realize I was doing it.

I don't know if this info means anything, but I ran a test to see what would happen.

I wrote a VI that creates a PopUpMenu with one entry, a submenu. The submenu had 10 items in it. I then just deleted the parent menu, and didn't do anything with the child menu. (I never called TrackMenu, I just created and destroyed. I assume this is not a factor)

Then I brought up the Win2K Task Manager, and included handles in the Process Window. I noted the numbers for Handles and available memory. I started my program. The handles number never seemed to change. Availiable memory would start shrinking, and then jump back up to where it started. (This is
what I expected to see.) After 5,000,000 iterations, everything still seemed the same. While the actual memory requirements for menus is probably small, I would think I would have seen the effect of 5 million orphan menus. Note that if I comment out DestroyMenu altogether, AppendMenu fails after about 1200 iterations (and LabVIEW bombs on the first user interaction)

The reason I'm so interested in this is because I only have 2 VI's to support PopUpMenu's; One to create them and one to track them. After I get the MenuItemID, I destroy the hMenu I tracked in the "Track" VI, making everything nice and neat (to me anyway).

All this is related to the TreeView ActiveX control that you helped me with earlier. In this case, if a user MouseDown's with the right button, I generate a PopUpMenu based on data the node (if any) represents. The Tag property of the Node tells me what "kind" of node it is (a value for a Case selector), which then grabs the appropriate data to build the PopUpMen
u (along with any submenus).

Once again, thank you very much for your help. I've learned a great deal in the last week or two trying to get my LV programs do what I want them to do.

Bob
0 Kudos
Message 8 of 8
(3,294 Views)