|
I have a problem with mapping keys to buttons on the dialog.
I tried by catching WM_CHAR message like this
void CDialogbasedDlg::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
switch(nChar)
{
case '1': //do sth
break;
//...
}
CDialog::OnChar(nChar, nRepCnt, nFlags);
}
but it didn't work. The application just beeps when I press '1'.
|
|
|
|
|
Does the dialog have keyboard focus ? Did you set a breakpoint ? Your code WILL do nothing when a '1' is pressed.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I put SetFocus() in OnInitDialog(), but I don't know anything about setting a breakpoint. Could you please, just in a few steps, explain me what I need to do?
|
|
|
|
|
You shouldn't have to call SetFocus, try removing it. A breakpoint is set with F9 ( from memory ), it's a little black circle on the left of your code. Then if you're in debug mode, when you run your program and it gets to the point where the circle is, it will stop and you can examine the state of memory/variables/etc. and step through code. The point here would just be to see if the code is being reached.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Ok I see what you mean. I know what debugging breakpoint is. I thought you ment it was some kind of a function or something similar. It doesn't work though. The code doesn't get executed.
I did manage, however, to trap keysrokes with PreTranslateMessage() like this
<br />
BOOL CDialogbasedDlg::PreTranslateMessage(MSG* pMsg) <br />
{<br />
if(pMsg->message==WM_CHAR)<br />
{<br />
switch(pMsg->wParam)<br />
{<br />
case '1':
break;<br />
case '2':
break;<br />
}<br />
return TRUE;<br />
} <br />
else<br />
return CDialog::PreTranslateMessage(pMsg);<br />
}<br />
and it works. But I guess this is not how it should be done. Is there a better way of trapping keystrokes in dialog?
|
|
|
|
|
This plainly means that the message is not getting through to your onChar handler. The question is, why ? Did you remove the SetFocus call ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Yes, i did. But how can I set focus to dialog so it can receive WM_CHAR?
I put TRACE macro in OnChar, but I dont get any results in the debug screen.
|
|
|
|
|
hi everybody,
i've got a strange error while trying to use va_start() macro.
i wrote the following :
va_list ap;
<font style="color:green;">
va_start(ap, 0); <font style="color:green;"></font> and the compiler gave me an error C2101: '&' on constant
when i looked at the MSDN, the example is that one :
int average( int first, ... )
{
va_list marker;
va_start( marker, first ); <font style="color:green;"></font>
<font style="color:green;">
}
it seems to be similar with my code, so i don't understand where i fail...
can anyone help please ?
TOXCCT >>> GEII power
|
|
|
|
|
The second argument must be the name of an argument in your function.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
but where is the difference ???
if the argument is an integer, its value will be passed... no ?
va_start() need a reference ?
does it need a reference to the first argument of the list ?
TOXCCT >>> GEII power
|
|
|
|
|
The difference is the fact that va_start() is a *macro*. The word "first" is literally passed to it, and it is then used.
va_start() uses it's second argument by doing &MySecondArg, this is why you get the "& on constant" error (0 in your case).
This is because va_start() needs to know where from the stack to read next. Since the second argument you pass to it is one of your function's arguments, taking it's address returns a place on the stack. From there, va_arg() keeps moving.
The va_list is simply a pointer to the next place, and this is what gets updated every time you use va_arg().
-- Calius
|
|
|
|
|
ok, well i can now say that, you are right for some points, but some other are wrong.
first (for precision), i've already said in my first post that va_start() was a macro ; knowing whatever it means.
in fact, va_start() get a reference to the argument preceding the first of the optional parameter... (so, you're right on this). i so now understand the compiler error (C2101).
but va_list is not a pointer to the next place as you say. it points only one argument (the current), and at the next call of va_arg() , this one will increment the pointer to the next argument in the list. that's why va_start() argument must be the preceding...
anyway, thanks, i apreciate your answer.
i'm now ok with that point...
TOXCCT >>> GEII power
|
|
|
|
|
<br />
#define va_start(ap,v) ( ap = (va_list)&v + _INTSIZEOF(v) )<br />
#define va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )<br />
Ill let you meditate on this
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
i know i know, as i said, i found it !!!!!!!
thanks for reading ;P
TOXCCT >>> GEII power
|
|
|
|
|
I added one video player activex to my MFC base project (CamImage.oce from Axis.com).
Its class name is CAxisCamContror drived from CWnd
|
|
|
|
|
Hi all, I'm developing a filter driver for an audio device and for installation, i'm using and custom made application instead of an inf. For installing the filter driver, I need to insert the service name into the HKLM\CurrentControlSet\Enum\<device-type>\<vendor-id>\<sub-value>. But as i understand, this is a protected area of windows registry and needs permission to be added for the current user. How do i do this in my program? RegOpenKeyEx() fails opening this key. Something like this has been done in an application i ran across a couple of weeks ago (cant seem to find it right now... i think it was from numega). Is there any other suggestions on installing the filter driver? thank you.
-Tareq
|
|
|
|
|
Have you tried installing the filter driver by using an .inf file ? Why can't you use the .inf file ?
I believe you can't write to this area of the registry directly, but your application could try calling RegSrv32 to register the filter driver from it's DLL when it is started, and removing it upon exit ?
Leaving it there is also an option, and you might write a setup program that registers the filter driver if it is not yet registered. And remove it when the application is removed from a system.
If you find the name of the application you mentioned, post it here as well.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
|
Got it to work using SetupDiSetDeviceRegistryProperty() ... didnt know of this.
-Tareq
|
|
|
|
|
Hi All
Im geting the compiler error
error C2440: '=' : cannot convert from 'short (__thiscall CMSComm::*)(void)' to 'short'
on this line
sCommEvent = m_ctlMSComm.GetCommEvent;
sCommEvent is a short and m_ctlMSComm is the control varable for the MSComm ActiveX control
is this error saying it cant convert from a short to a short.
im using VC++ 6
Cherrs Ketil
|
|
|
|
|
|
Its OK figerd it out
I will get me cote
|
|
|
|
|
I having a problem with a control (say an edit box) on a Dialogue or FormView.
in my resource script is as follows
EDITTEXT IDC_EDIT1,34,50,26,14,ES_AUTOHSCROLL | NOT WS_BORDER<br />
PUSHBUTTON "&Size Info",IDC_SIZE_INFO,69,91,56,26<br />
<br />
I've a handler for the button
as follows:
-
<br />
void CMyDialog::OnSizeInfo()<br />
{<br />
CRect ButtonRect, EditRect;<br />
CWnd *pEdit = GetDlgItem(IDC_EDIT1);<br />
CWnd *pButton = GetDlgItem(IDC_SIZE_INFO);<br />
pEdit->GetClientRect(EditRect);<br />
pButton->GetClientRect(ButtonRect);<br />
}<br />
-
<br />
void CMyDialog::OnSizeInfo()<br />
{<br />
CRect ButtonRect, EditRect;<br />
CWnd *pEdit = GetDlgItem(IDC_EDIT1);<br />
CWnd *pButton = GetDlgItem(IDC_SIZE_INFO);<br />
pEdit->GetWindowRect(EditRect);<br />
pButton->GetWindowRect(ButtonRect);<br />
}<br />
-
<br />
void CMyDialog::OnSizeInfo()<br />
{<br />
CRect ButtonRect, EditRect;<br />
CWnd *pEdit = GetDlgItem(IDC_EDIT1);<br />
CWnd *pButton = GetDlgItem(IDC_SIZE_INFO);<br />
::GetClientRect(pEdit,EditRect);<br />
::GetClientRect(pButton,ButtonRect);<br />
}<br />
-
<br />
void CMyDialog::OnSizeInfo()<br />
{<br />
CRect ButtonRect, EditRect;<br />
CWnd *pEdit = GetDlgItem(IDC_EDIT1);<br />
CWnd *pButton = GetDlgItem(IDC_SIZE_INFO);<br />
::GetWindowRect(pEdit,EditRect);<br />
::GetWindowRect(pButton,ButtonRect);<br />
}<br />
in all cases the top and left properties are 0 and 0 and not 34 and 50 (EditRect) or 69 and 91 (ButtonRect). How I get this programatically.
Many thanks
Alton
|
|
|
|
|
You can :
CPoint pt(0,0);
child->ClientToScreen(&pt);
parent->ScreenToClient(&pt);
I believe pt will now contain the position of child relative to parent.
|
|
|
|
|
i want to buit an application that can connect two pc's using LPT1 using LAPlink cable. can some body send me this source code developed in C++. or help me in any other way.
|
|
|
|