Author Topic: SendMessage and hidden windows  (Read 8748 times)

0 Members and 1 Guest are viewing this topic.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16897
  • Superior Stupidity at its best
SendMessage and hidden windows
« on: June 23, 2004, 12:56:53 AM »
Ok, here is one for someone to speculate on, I have yet to find out the reason for it ....

I have created a form, that has a property VISIBLE = False, I do not want the user to see the form when the program runs, I only want it to initialize and store data in the form, this form will load when Windows starts.

If I programmatically change the value to VISIBLE = True, the form shows and all is well, there is a time when I WANT the form to show....

Anyway, what I am doing is creating a routine in the program that if the user starts the program from the icon, with no command line parameters (IE from an executable), it will detect the form is already loaded and not attempt to load another instance ... i.e. if App.PrevInstance = True

Now, if App.PrevInstance is true, I can find the hidden window programmatically, but I cannot seem to get it accept the SendMessage command...

i.e.

Code: [Select]

SendMessage (App.Form1.hWnd, WS_VISIBLE, 0&, 0&)


Theoretically, this should change the visible property to true and repaint the window, but I have not had any luck....

Oh, and yes, in this project I have managed to do all of the following so far with pretty good success....

Interface with the AutoCAD VBE environment and dynamically load/unload VBA projects, Send lisp and vlisp commands to AutoCAD, Load/Unload Arx modules,  Call Win APIs, VBA, and VB and JavaScript functions and dynamically link to type libraries to solve the VB5/VB6 and AC15/AC16 problems associated with declaring type libraries in the reference window.

I just need to be able to set the visible flag to true on a VB Form by only knowing it's handle

Any Takers???
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Trev

  • Guest
SendMessage and hidden windows
« Reply #1 on: June 23, 2004, 02:52:50 AM »
My first thought is that if you are just creating the form to store data in (I assume to retrieve on later instances of running program & or to change or store default values etc.) Why not write those values into the registry? create a registry key for your program & store the data there.
Maybe an alternative solution at least.

hendie

  • Guest
SendMessage and hidden windows
« Reply #2 on: June 23, 2004, 03:47:24 AM »
that's way over my head Keith, I've never had the chance to study that stuff so any suggestions I make are purely grasping at straws...
here's a couple of things I found but I've no idea if they have any relvance....

Applications create their main window by calling CreateWindow with the WS_VISIBLE flag set.
Applications create their main window by calling CreateWindow with the WS_VISIBLE flag cleared, and later call ShowWindow with the SW_SHOW flag set to make it visible.

The UpdateWindow function updates the client area of the specified window by sending a WM_PAINT message to the window if the window's update region is not empty. The function sends a WM_PAINT message directly to the window procedure of the specified window, bypassing the application queue. If the update region is empty, no message is sent.

I also found something (and lost it) about even although a window may be visible, it requires to be enabled to recieve commands

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16897
  • Superior Stupidity at its best
SendMessage and hidden windows
« Reply #3 on: June 23, 2004, 02:57:20 PM »
Ok, the reason I have the proggie starting not visible is because the information I am gathering takes a bit of time to gather and I want to gather it at startup, this way when the user needs it, it is already done, and there is no waiting. Oh and the information would be way too large to hold in the registry.

 Also there will never be more than one instance of the program because I am doing a search for the window title using the GetWindow API, returning the handle of the window and then modifying it as needed, and then closing the new instance.

I think you may have hit upon something Hendie, I will try to set the WM_PAINT and/or the SW_SHOW calls with the ShowWindow API ...

Thnx... I will let you know the prognosis later ... once I get it all sorted out...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Anonymous

  • Guest
SendMessage and hidden windows
« Reply #4 on: June 23, 2004, 03:20:50 PM »
Perhaps this reference will help (or not).

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
SendMessage and hidden windows
« Reply #5 on: June 23, 2004, 03:22:28 PM »
Quote from: Anonymous
Perhaps this reference will help (or not).

Sorry, didn't realize I wasn't logged in. :roll:
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

hendie

  • Guest
SendMessage and hidden windows
« Reply #6 on: July 01, 2004, 06:55:12 AM »
Quote from: Keith
... I will let you know the prognosis later ... once I get it all sorted out...


and the answer was....

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16897
  • Superior Stupidity at its best
SendMessage and hidden windows
« Reply #7 on: July 01, 2004, 08:16:50 AM »
I don't have the code in front of me at the moment... but if my memory serves me correct, I found that the problem was entirely to do with the handle being incorrect, and the final function call was the SW_SHOW message

I found out that the handle returned by VB is completely different from the handle returned by C++ and as such, if you use the VB call to return the handle it is useless in C++ defined calls, go figure...I found it out quite by accident, so once I knew that, I quit using the Form.Hwnd and started using the API FindWindow and it worked beautifully.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie