You shouldn't be running the message loop at all in window(), this is already done by mIRC. By hooking mIRC's windowproc, you only need to process that window procedure and return. Create the window, hook the windowprocs, and return. If you *do* need to run your own message loops, you should be initializing them in LoadDll (or via the global window hook as a message), not from within window(), otherwise you will create an infinite loop in your dll call. Note that this is the whole point of a "message loop". It is an infinite loop to keep the "program" from returning (and by extension, to keep it processing messages). A message loop must inherently run until the "program" (dll in this case) finishes doing everything it needs to do. This means that everything you do needs to work within your message loop, not the other way around. DLL calls should simply post messages to your existing message loop (mIRC's message loop if you want) which is processed elsewhere.

In short, you don't need a message loop. Since you set your DLLWindowProc function as the WindowProc callback for your newly created window, all window messages are already being passed to that function automatically. It's being done through mIRC's main message loop-- you don't need to implement your own.

The only problem is that the messages won't come in with some MY_MSGLOOP flag. In fact, that wouldn't have worked anyway, so you should ditch that code. Instead, you should simply check the HWND parameter in your WindowProc callback function-- if it's one of your hwnd's, process, else call mIRC's callback:

Code:
if (hwnd == MY_HWND) {
  switch(message) { ... }
}
else {
  return CallWindowProc(mWndProc, ...);
}


If you want to support multiple windows you'll need to loop over a list instead of a single == MY_HWND check, obviously. Either that or, if multiple windows is a serious goal, you could consider actually making your own custom message loops for each window, but that's way more complicated than you need to deal with, and it would still require you to loop over each window, so it's more work, if anything.

On another note, I'm a little confused as to what you're trying to return to mIRC? Why do you even need to return something? It just looks like you're initializing a window. you could just return 1;


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"