Mouse events in Dev-C++

Archives Forums/Blitz3D SDK Programming/Mouse events in Dev-C++

Moraldi(Posted 2007) [#1]
I can't catch mouse events in my main window procedure with Blitz3D SDK in action
Does anyone knows how can I detect these events?

Thanks!


b32(Posted 2007) [#2]
Have you tried using the SetBlitz3DEventCallback function ?

My c++ isn't all that, but I suppose it should be something like this:
SetBlitz3DEventCallback(*bbcallback);

(The star sign should mean that it is a pointer to the function)

//found this in google as being a standard callback procedure:
LRESULT CALLBACK bbcallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{

 if (message == WM_MOUSEMOVE)
 {
   ...
 }

}



Moraldi(Posted 2007) [#3]
You are right b32!.
I tried the SetBlitz3DEventCallback and it works now

int BBEventHandler(int hwnd, int msg, int wp, int lp)
{
  PostMessage((HWND)mymainHWND, msg, wp, lp);
  return -1;
}


This is strange because of 2 reasons:
1. I receive keyboard messages in my main window procedure without setting up an event handler
2. As you can see in this piece of code I don't need the argument hwnd because I don't know in which window it belongs...

Thanks!


b32(Posted 2007) [#4]
I suppose that the blitz3d window is comparable to a panel, or something, which is why it can't have 'focus' like for instance an edit, or a button. (No tabstop etc.) Because of that, the key events will still be sent to the main form.
And I think that the hwnd that is passed from the event handler is the directx device hwnd from b3d. So I think that the mainform is it's parent, except if you use SetHwnd, than that component will be its new parent.


Pepsi(Posted 2007) [#5]
Good job! That PostMessage works perfectly with a child windowed blitzapp. I would have never guessed to used it.

Was there some kind of documentation or post other than the blitzmax stuff that showed us how to use eventhandler with postmessage?

I remmember the C/C++ one, but it left the EventHandler empty leaving unwanted results(ie: no input, process wont end on app exit... ).

Well, at least now i finally know how to use it correctly. Thanks guys.


Pepsi(Posted 2007) [#6]
Arg... to quick to say "perfectly"... still can not access the blitz keyboard commands outside of the blitzapp child window. But, I see I can still use the mouse commands. So it IS still broken :/


Moraldi(Posted 2007) [#7]
Pepsi:
Can you describe in more detail what do you want to do?
Thanks!


Pepsi(Posted 2007) [#8]
With EBasic, I made a simple app where I have my main window and created a child window from that. Ofcoarse I set bbSetBlitz3DHWND to the child window handle.

Now, I have the child blitz window covering the right half of the main window. The idea here is to use the EBasic's GUI controls in the left side of the main window.

Without calling the bbSetBlitz3DEventCallback, I simply have no input control in the child blitz window. Now, calling the bbSetBlitz3DEventCallback command with the EventCallback routine, Im able to work with Blitz's mouse commands inside and outside of the child window.

But still using a child blitz window to do the rendering in, the blitz keyboard commands(ie: bbKeyHit...) still does not work.

Yes, I know while using the event handler callback, I can create my own vk keys froms the data returned from the callback.

But, I do not want to be arsed with that. I want to use the bbKeyHit command so I can use the scancode variables(ie: KEY_ESCAPE, KEY_SPACE, KEY_A, etc...).

-----

Anybody have c/c++ code to read scancodes like Blitz? I wouldnt mind using that temporarily as we tiresly wait for an update to fix this problem. thx

OR, if Im totally missing something on how to use blitz3dsdk's bbkeyhit command while it's rendering in a child window, please fill me in. thx


b32(Posted 2007) [#9]
I don't think that is really a bug, it is the same way that Blitz3D programs respond. When the window is inactive, MouseX() keeps responding, but KeyDown() doesn't.
As an alternative, you could maybe use the GetASyncKeyState command. Something like:
if(!GetASyncKeyState(VK_RETURN))
{
  ..
}



Pepsi(Posted 2007) [#10]

I don't think that is really a bug, it is the same way that Blitz3D programs respond. When the window is inactive, MouseX() keeps responding, but KeyDown() doesn't.



guess im sol then...


Moraldi(Posted 2007) [#11]
b32:
Use GetAsyncKeyState function with care...
http://www.blitzbasic.com/Community/posts.php?topic=71387
Pepsi:
After setting up a Blitz3DSDK event handler your main window will be able to catch keyboard messages right?
Then you can send any keyboard messages from your main window to your child. Did you try this?
here is my pseudo code :
Function MyMainWindowMessageHandler(hwnd, msg, lparam, wparam)
{
  switch (msg)
  {
    case keyboardmessage:
      PostMessageTo ChildWindow
      break;
    .
    .
    .
  }
}




Pepsi(Posted 2007) [#12]
Yes, in my first post in this thread, the 4th line from the bottom, I was saying that I know how to get data( messages ) from the callback( ie: I can set up my own vk_key table ). But, my whole point was that blitz3dsdk should be able to have functioning blitz keyboard commands even in a blitz3dsdk controlled child window.

b32 says this is pretty much the same behaviour as the regular blitz3d product itself. So, basically what I want would be a feature request. I know that a single person like me that asks for feature request on the blitz forums is pretty much saying that im sol'd.

I just want the ease of use of the blitz command set in other languages. I would think that the blitz keyboard commands not working when a blitz app is running in a child window shouldn't be ignored.

* sounds like im ranting, I apologize for that.