按下Win API C ++按钮 [英] Handle Win API C++ button press

查看:68
本文介绍了按下Win API C ++按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想在原生窗口中处理c ++ win32 API按钮,我现在正在尝试这样做 -



http://pastie.org/10845044< - 代码可以在这里找到,http://stackoverflow.com/questions/37342605/win32-c-handle-button-press-peekmessage-not-工作 - 为SO帖子



当我加载OBS时,包括  dll  
发生的是 -


  1. OBS开始
  2. Window pops u
  3. 我点击窗口
  4. 什么都没发生



其中在第4步,点击按钮后,MessageBox应该弹出说 -   MessageBox(hWnd,
L" else",L" else",0);
  if if into into the else,if if statement  ;
true
然后  MessageBox(hWnd,
L" if",L" if",0);



但是我的代码甚至不会进入回调函数,为什么会这样?

解决方案

从粗略看看stackoverflow上的代码看来,窗口类的注册注册了一个窗口过程名称WndProc。然而,显示的代码在一个名为WindowProcedure的函数中。 


假设您的代码已针对所指出的错误(包括按钮单击处理)进行了更正并实际编译并运行,则WindowProcedure函数将永远不会被调用,因为它是在类注册中指定的WndProc。


当然,如果你发布了你在这里使用的ACTUAL代码会更好。



I want to handle a c++ win32 API button press in a native window, I'm currently attempting doing it like so -

http://pastie.org/10845044 <- code can be found here,http://stackoverflow.com/questions/37342605/win32-c-handle-button-press-peekmessage-not-working - for the SO post

When I currently load OBS, after having included the dll what happens is -

  1. OBS starts
  2. Window pops u
  3. I click on window
  4. Nothing happens

where on step 4, right after clicking on the button a MessageBox should popup saying - MessageBox(hWnd, L"else", L"else", 0); if it goes into the else, and if the if statement is truethen MessageBox(hWnd, L"if", L"if", 0);

However my code won't even enter the callback function, why is this?

解决方案

From a cursory look at the code on stackoverflow it appears that the registration of the window class registers a window procedure name WndProc.  However, the code displayed is in a function named WindowProcedure. 

Assuming that your code was corrected for the errors noted (including button click handling )and actually compiles and runs, the WindowProcedure function will never be called since it is WndProc that is specified in the class registration.

Of course it would be better if you posted the ACTUAL code you are using here.


这篇关于按下Win API C ++按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆