|
Yea kinda, i know of that, as ive used while left button down, but i cant find out how to do while scroll wheel down...
/Johannes
|
|
|
|
|
Johpoke wrote: ive used while left button down...
Why would you be using WM_MBUTTONDOWN with the left mouse button?
Johpoke wrote: but i cant find out how to do while scroll wheel down...
What about WM_MOUSEWHEEL ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
He said MBUTTON, not LBUTTON right?
Check this out: About Mouse Input[^]
especially the section "The Mouse Wheel"
|
|
|
|
|
Yea thats it, i need to use these;
WM_MBUTTONDOWN //The middle mouse button was pressed.
WM_MBUTTONUP //The middle mouse button was released.
i read at http://msdn2.microsoft.com/en-us/library/ms645601.aspx
but i cant find out how to use it.. it needs windows.h, but what else do i need to do? so that this can work:
while(true)
{
while(WM_MBUTTONDOWN == TRUE)
{
//does when it down
}
}
thanks
EDIT: its important that it works globaly, so i can have this minimized and im working in another app and it should still detect it
/Johannes
|
|
|
|
|
Johpoke wrote: but i cant find out how to use it.. it needs windows.h, but what else do i need to do?
Uh oh. Have you written a windows app yet? WM_MBUTTONDOWN is a message sent by the system to
the window with focus. How you respond to this message in code is different with straight C/C++
than MFC. Maybe you have some studying to do??
|
|
|
|
|
Uh oh, well i havent done any of the programing yet, ille do that part when i know i can get this to work, so for me it doesnt matter if its mfc, win32, win32 console or anything.. just as long as its c++... is it hard to detect middle mouse globaly?
/Johannes
|
|
|
|
|
Johpoke wrote: is it hard to detect middle mouse globaly?
"hard" is relative. I imagine it's hard if you've never written a windows app before.
An understanding of Windows messaging is necessary for sure
|
|
|
|
|
ah sounds like ille have to ditch that idea..
thanks anyway
/Johannes
|
|
|
|
|
You can trap the WM_MBUTTONDOWN and WM_MBUTTONUP messages or you can use the GetAsyncKeyState() function.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
|
My app has a main dialog window. By using PreTranslateMessage() it looks for pressed keys. When a certain key is pressed and held down a popup dialog window appears. When the key is released the window is supposed to close but it doesn't.
The code works in such way that as long as the key is pressed an if-statement is true. In the statement there is a
m_dlgMenu.ShowWindow(SW_SHOW);
which shows the popup dialog.
When the key is released the if-statement is false and a
m_dlgMenu.ShowWindow(SW_HIDE);
is called to close the popup.
The problem is that the popup window isn't closed until the mouse is moved. What may be the reason for this? It seems like it waits for a message before the popup is closed.
Thanks for any help!
|
|
|
|
|
Can you post your PreTranslateMessage() code?
Where is this "if-statement" you speak write of?
|
|
|
|
|
Actually I made a simplification when I described the problem. The PreTranslateMessage() checks for a TAB-keypress and as long as TAB is held down it calls CCameraControlDlg::ManualMode()
The CCameraControlDlg is the main dialog.
BOOL CCameraControlDlg::PreTranslateMessage(MSG* pMsg) <br />
{<br />
<br />
if (GetAsyncKeyState(VK_TAB) < 0) { <br />
CCameraControlDlg::ManualMode();<br />
}<br />
Sleep(10);<br />
return CDialog::PreTranslateMessage(pMsg);<br />
<br />
}
In the CCameraControlDlg::ManualMode() function there are again and if-statement. This look for F2-keypresses as shown below. As long F2 is held down it calls the MouseScroll-function which is used for scrolling up and down a menu in the other dialog. Then m_dlgMenu.ShowWindow(SW_SHOW) are used to show the other dialog. When the F2-key is released the other if-statement will be true and should hide the window. But nothing happens until the mouse is moved (the TAB-key is still pressed).
<br />
void CCameraControlDlg::ManualMode() {<br />
.<br />
.<br />
.<br />
<br />
if ((GetAsyncKeyState(VK_F2) < 0) && ((control_nr == 2) || (control_nr == 0))) { <br />
<br />
x_F2 = MouseScroll(menu_roof, reset_val);<br />
<br />
m_dlgMenu.ShowWindow(SW_SHOW);<br />
m_dlgMenu.m_strHeader.Format("White Balance");<br />
m_dlgMenu.m_strChoice.Format(menu_text_F2[x_F2]);<br />
<br />
m_dlgMenu.UpdateData(FALSE); <br />
<br />
control_nr = 2;<br />
<br />
}<br />
<br />
else if (control_nr == 2) {<br />
<br />
m_dlgMenu.ShowWindow(SW_HIDE)<br />
control_nr = 0;<br />
}<br />
<br />
.<br />
.<br />
.<br />
}<br />
Another thing is that it works as expected if the style of the other dialog is set to "child" instead of "popup" but when F2 is held down the dialog flickers a couple of times before it is shown , which is annoying. This is not the case when the style is "popup".
Thanks for your help
|
|
|
|
|
Hehe, got it to work
I placed a PreTranslateMessage() in the code for the other dialog and it called OnOK() when GetAsyncKeyState(VK_F2) == 0
|
|
|
|
|
hi , i m new n i just managed one clinet server prg but i am not able to connect multiple client to my server.
|
|
|
|
|
<--- maybe that's the problem!
Have you written your server to accept multiple clients?
Bare minimum, I imagine you'll at least need to keep a list/array of SOCKETs.
|
|
|
|
|
Probably should have sent him a McDonalds menu.
led mike
|
|
|
|
|
I actually had a filet-o-fish for lunch. What does this say about my programming "skills"?
Hanging my head in shame,
Mark
|
|
|
|
|
tks for help i am dont with my project
|
|
|
|
|
I'm sorry to ask such a simple question but my compiler is spitting out errors and dosen't recognize CString. I can't figure out what's wrong. String works fine though. I'm trying to use it for MFC. Here is the code:
include <iostream>
#include <string>
#include <cstring>
#include <cstddef>
#include <cctype>
using namespace std;
int main()
{
CString Test;
Test = "It Worked!";
cout<<Test;
cin.get();
return 0;
}
Thanks.
|
|
|
|
|
What errors on what lines?
Are these still the include files for VC 2005?
#include <cstringt.h> //MFC-only string objects
#include <atlstr.h> //Non-MFC string objects
|
|
|
|
|
Thanks for the help (all). I got that part of it fixed. The problem is that it's now causing another error:
fatal error C1189: #error : WINDOWS.H is already included. MFC Apps must not #include <windows.h>.
I've checked every single include statement, and Windows.H isn't there. It might be a dependancy of one of the include files though. I'm also being forced to use cstringt.h in my MFC classes and atlstr.h in my non-MFC classes, all in the same project. It's unlikely but that might have something to do with it. Here is all of my include files, if someone could look at them please:
"phone_interface.cpp"
#include <cstringt.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <strstream>
#include "phone_interface.h"
#include <afxwin.h>
//File Name: "sort.rc"
#include <afxres.h>
#include <phone_ids.h>
//File Name: "phone_main.cpp"
#include <cstdlib>
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <strstream>
#include <phone_interface.h>
#include <afxwin.h>
#include <phone_ids.h>
//File Name: "phonebook_class.cpp"
//File Description: Implementation file for PhoneBook class
#include <iostream>
#include <string>
#include <fstream>
#include <cstddef>
#include <atlstr.h>
#include <sstream>
#include "phonebook_class.h"
#include "defenitions.h"
//File Name: "usermenu_class.cpp"
//File Description: Implementation file for UserMenu class
#include <iostream>
#include <string>
#include <cctype>
#include "usermenu_class.h"
#include "phonebook_class.h"
#include "defenitions.h"
//File Name: "Common_Defenetions.h"
//Description: Common header file for structure and enumeration defenitions.
#ifndef DEFENITIONS_H
#define DEFENITIONS_H
#include <iostream>
#include <string>
//File Name: "phone_interface.h"
#ifndef PHONE_INTERFACE_H
#define PHONE_INTERFACE_H
#include <iostream>
#include <string>
#include <strstream>
#include <fstream>
#include <afxwin.h>
#include "usermenu_class.h"
//File Name: "phonebook_class.h"
//File Description: Decleration file for PhoneBook class
#ifndef PHONEBOOK_CLASS_H
#define PHONEBOOK_CLASS_H
#include <iostream>
#include <cstddef>
#include <string.h>
#include <sstream>
#include <atlstr.h>
#include "defenitions.h"
//File Name: "usermenu_class.h"
//Description: Declaration file for UserMenu class
#include <iostream>
#include <string>
#include "defenitions.h"
#include "phonebook_class.h"
Sorry for the long post. Thanks for the help.
|
|
|
|
|
#include <afxwin.h> //<--- this pulls in windows.h
I would recommend creating a temp MFC project that is close to the type of project you are
working on. Then take the stdafx.cpp and stdafx.h from that temp project and copy them to your
project. stdafx.h is the default pre-compiled header file and should be included at the top of every
cpp file in your project. Make sure in your project settings - C/C++ - Precompiled headers -
Create/Use PCH through file setting is set to stdafx.h. This should give you most, if not all, of
the headers you'll commonly need.
|
|
|
|
|
I'm sorry, I think the forum chopped off the include file you were talking about. Can you check the "Ignore HTML tags in this message" box below the smilies please.
|
|
|
|
|
I always do that!
#include <afxwin.h> //<--- this pulls in windows.h
I would recommend creating a temp MFC project that is close to the type of project you are
working on. Then take the stdafx.cpp and stdafx.h from that temp project and copy them to your
project. stdafx.h is the default pre-compiled header file and should be included at the top of every
cpp file in your project. Make sure in your project settings - C/C++ - Precompiled headers -
Create/Use PCH through file setting is set to stdafx.h. This should give you most, if not all, of
the headers you'll commonly need.
|
|
|
|