Ok, I have code that needs to forever loop, and process. My code in the windows procedure has a case WM_LBUTTONDOWN: . I left click on the client area of the window and it processes the code accordingly. Now so that it keeps processing code at the end of the code I SendMessage(hwnd,WM_LBUTTONDOWN,0,0); so that it then sends my application a constant left mouse button down command, and loops the code over and over.
The problem is when I go to close my program either by the X at the top right, or using the right button of my mouse which has code to destroy the application. It hangs, and does not terminate the program,and windows takes over and kills the program some time after.

For the game cheats I am developing I basically created a small window for each program that is to loop the code, and each hangs whenever you try to close them.
I dont want my users to have to have 7 little windows running on their desktop, and 7 windows which take forever to close usually requiring task manager to close them.
Im still new to windows api here, but im sure theres something I could do, or am not doing.

[Question]
When time comes that I create one parent application with buttons to run all these stubs. I was wondering if I set each button to open an invisable child window to do this looping\processing, and a corresponding OFF button to destroy the invisable child window might be my only choice. What I dont know is will it "HANG" my parent window from further processing with these multiple invisable child windows?

I am here because I feel my ignorance is blind to an easier way. So any suggestions or direction would greatly be appreciated!

Recommended Answers

All 4 Replies

>>The problem is when I go to close my program either by the X at the top right, or using the right button of my mouse which has code to destroy the application. It hangs, and does not terminate the program

Most likely because it is processing all those WM_LBUTTONDOWN event messages. Use the compiler's debugger and find out if that is the cause or not.

Try setting a flag in the WM_CLOSE message to disable the WM_LBUTTONDOWN events.

How about instead of sending a WM_LBUTTONDOWN event, you just make a local loop in the window procedure. So something like

case WM_LBUTTONDOWN: 
while(TRUE)
{
//your loop
}

The problem with that loop is that it might stop the program from processing other windows messages, unless there is anther message pump like the one in main() within that loop.

I see your point, and I didn't even think of that. But sending a WM_LBUTTONDOWN message indefinitely seems like the wrong way to go about it. What might work better, is a function call, then do all of your processing in your function, with an infinite loop or not, but at least that way, other windows should have an easier time sending messages because he queue isn't full of WM_LBUTTONDOWN.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.