|
need4change wrote: pls can someone help me....
Yes, if you ask the right question. I don't see any question in your post. And your post is also very unclear. If you ask for people to do the job for you, be very carefull then. You'll be warned
|
|
|
|
|
I've got a c++ win32 (non MFC) dialog based app with a custom control
that listens to WM_KEYDOWN,WM_KEYUP for keypress/releases to
behave like a synth keyboard - so i NEED keyup events.
Thing is, it's BEEPING! (a "default beep" type beep)
In my custom control i've tried returning 0, returning 1 and
calling the default message handler - STILL beeps.
I tried with and without calling TranslateMessage() in my msgloop.
STILL BEEPS!
Can anybody help meee?
Here's my custom control - pretty basic:
(KeyMap and Canvas are my own classes, but are pretty simple and DON'T BEEP)
struct {key k; ubyte nt;} KyNt [] = {
{'z', M_NT(M_C,0)}, {'x', M_NT(M_D,0)},
{'c', M_NT(M_E,0)}, {'v', M_NT(M_F,0)},
{'b', M_NT(M_G,0)}, {'n', M_NT(M_A,0)},
{'m', M_NT(M_B,0)}, {',', M_NT(M_C,1)},
{'.', M_NT(M_D,1)}, {'/', M_NT(M_E,1)},
{'s', M_NT(M_Db,0)}, {'d', M_NT(M_Eb,0)},
{'g', M_NT(M_Gb,0)}, {'h', M_NT(M_Ab,0)},
{'j', M_NT(M_Bb,0)}, {'l', M_NT(M_Db,1)},
{';', M_NT(M_Eb,1)},
{'q', M_NT(M_C,1)}, {'w', M_NT(M_D,1)},
{'e', M_NT(M_E,1)}, {'r', M_NT(M_F,1)},
{'t', M_NT(M_G,1)}, {'y', M_NT(M_A,1)},
{'u', M_NT(M_B,1)}, {'i', M_NT(M_C,2)},
{'o', M_NT(M_D,2)}, {'p', M_NT(M_E,2)},
{'[', M_NT(M_F,2)}, {']', M_NT(M_G,2)},
{'\\', M_NT(M_A,2)},
{'2', M_NT(M_Db,1)}, {'3', M_NT(M_Eb,1)},
{'5', M_NT(M_Gb,1)}, {'6', M_NT(M_Ab,1)},
{'7', M_NT(M_Bb,1)}, {'9', M_NT(M_Db,2)},
{'0', M_NT(M_Eb,2)}, {'=', M_NT(M_Gb,2)},
{BSP_KEY, M_NT(M_Ab,2)}
};
struct CtlKbd {
public:
void Init ()
{
TRC("CtlKbd::Init bgn");
MemSet (& _wc, 0, sizeof (_wc));
_wc.lpszClassName = "KBD";
_wc.lpfnWndProc = WinProc;
_wc.cbSize = sizeof (WNDCLASSEX);
_wc.hCursor = ::LoadCursor (0, IDC_ARROW);
if (::RegisterClassEx (& _wc) == 0)
DieWn ("CtlKbd::CtlKbd RegisterClassEx");
TRC("CtlKbd::Init end");
}
private:
WNDCLASSEX _wc;
static LRESULT CALLBACK WinProc (HWND hwnd, UINT msg, WPARAM w, LPARAM l)
{ static bool foc = false;
static ubyte oct = 4;
static ubyte vel = 100;
switch (msg) {
case WM_LBUTTONDOWN:
::SetFocus (hwnd);
return 0;
case WM_SETFOCUS:
foc = true; ::RedrawWindow (hwnd, NULL, NULL, RDW_INVALIDATE);
return 0;
case WM_KILLFOCUS:
foc = false; ::RedrawWindow (hwnd, NULL, NULL, RDW_INVALIDATE);
return 0;
case WM_PAINT:
{ PAINTSTRUCT p;
Canvas c (::BeginPaint (hwnd, & p));
c.SetBg (foc ? 0 : 255, foc ? 255 : 0, 0);
c.Text (0, 0, "in");
::EndPaint (hwnd, & p);
}
return 0;
case WM_ERASEBKGND:
return 0;
case WM_KEYDOWN: case WM_KEYUP:
{ KeyMap km;
key k;
ubyte i;
TrkEv e;
char buf [900];
if ((l & 0x80000000) || (!(l & 0x40000000))) if (k = km.Map (w)) {
for (i = 0; i < BITS (KyNt); i++)
if (k == KyNt [i].k) {
e.ctrl = (ubyte)(KyNt [i].nt + oct*12);
e.valu = (l & 0x80000000) ? 0 : vel;
if ((l & 0x80000000) == 0) e.valu |= 0x80;
e.chan = 0;
sprintf (buf, "kbd ctl: $%02X $%02X\n", e.ctrl, e.valu);
DBG(buf);
break;
}
}
return 0;
}
}
return ::DefWindowProc (hwnd, msg, w, l);
}
};
|
|
|
|
|
Seems to me you could play around with the various messages you are handling by calling DefWindowProc() instead until you find the message that is in question. From there, you could narrow it down to the actual statement that is causing the problem.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
Well, I suspect the DefWindowProc itself is actually DOING the beeping.
But I don't know why???
I must be doing something wrong, but I don't know what...
|
|
|
|
|
Hmm, I took everything out and it still beeps.
So it has to be due to IsDialogMessage of the MsgLoop
or DefWindowProc of my custom control...
When focus is on a combo box, holding down keys doesn't cause "default beep".
But when my custom control has focus it DOES do the "default beep".
Maybe my control has to say "hey i need keypresses" so IsDialogMessage doesn't
beep (I'm guessing due to not being able to navigate to a static with that mnemonic???)
Hmmmmmmmmmm......
(And thanks for the reply!)
...Steve
|
|
|
|
|
Ok. I needed to handle WM_GETDLGCODE for my custom control to get wm_keyup/down...
No more beeping.
Buuuut, now I can't tab outa the field once I'm in it.
I can click out, but can't tab/shift-tab out...
Anybody know how to correctly handle tab, shift-tab, cursor up/down/left/right, mnemonic???
Sighhh...
...Steve
struct CtlKbd {
public:
void Init ()
{
TRC("CtlKbd::Init bgn");
MemSet (& _wc, 0, sizeof (_wc));
_wc.lpszClassName = "KBD";
_wc.lpfnWndProc = WinProc;
_wc.cbSize = sizeof (WNDCLASSEX);
_wc.hCursor = ::LoadCursor (0, IDC_ARROW);
if (::RegisterClassEx (& _wc) == 0)
DieWn ("CtlKbd::CtlKbd RegisterClassEx");
TRC("CtlKbd::Init end");
}
private:
WNDCLASSEX _wc;
static LRESULT CALLBACK WinProc (HWND hwnd, UINT msg, WPARAM w, LPARAM l)
{ static bool foc = false;
static ubyte oct = 4;
static ubyte vel = 100;
switch (msg) {
case WM_GETDLGCODE:
return DLGC_WANTALLKEYS;
case WM_LBUTTONDOWN:
::SetFocus (hwnd);
return 0;
case WM_SETFOCUS:
foc = true; ::RedrawWindow (hwnd, NULL, NULL, RDW_INVALIDATE);
return 0;
case WM_KILLFOCUS:
foc = false; ::RedrawWindow (hwnd, NULL, NULL, RDW_INVALIDATE);
return 0;
case WM_PAINT:
{ PAINTSTRUCT p;
Canvas c (::BeginPaint (hwnd, & p));
c.SetBg (foc ? 0 : 255, foc ? 255 : 0, 0);
c.Text (0, 0, "in");
::EndPaint (hwnd, & p);
}
return 0;
case WM_ERASEBKGND:
return 0;
case WM_KEYDOWN: case WM_KEYUP:
{ KeyMap km;
key k;
ubyte i;
TrkEv e;
char buf [900];
if ((l & 0x80000000) || (!(l & 0x40000000))) if (k = km.Map (w)) {
for (i = 0; i < BITS (KyNt); i++)
if (k == KyNt [i].k) {
e.ctrl = (ubyte)(KyNt [i].nt + oct*12);
e.valu = (l & 0x80000000) ? 0 : vel;
if ((l & 0x80000000) == 0) e.valu |= 0x80;
e.chan = 0;
sprintf (buf, "kbd ctl: $%02X $%02X\n", e.ctrl, e.valu);
DBG(buf);
return 0;
}
}
break;
}
}
return ::DefWindowProc (hwnd, msg, w, l);
}
};
|
|
|
|
|
Steve Hazel wrote: case WM_GETDLGCODE:
return DLGC_WANTALLKEYS;
What about DLGC_WANTARROWS and DLGC_WANTTAB ?
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
handling WM_GETDLGCODE with return DLGC_WANTALLKEYS tells the dialog manager
that I want keys and to NOT beep when a key doesn't resolve to a static to navigate to.
The keys I want to watch go up and down don't include arrows or tab.
I was -hoping- that the msgloop's IsDialogMessage() or control's DefWindowProc
would handle tabbing(and shift tabbing and arrowing) to other controls,
but noooooo...
So now I gotta figure out how to correctly tab/shift-tab/etc...
...Steve
|
|
|
|
|
How about changing it to DLGC_WANTCHARS instead, so the dialog manager will still process the arrow keys and the tab character if the IsDialogMessage is properly introduced into whatever main message loop you have for your application.
If not, then you need to handle the arrow keys and TAB/SHIFT+TAB your self and translate them into setting focus of appropriate next and previous dialog controls.
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
Not sure about DLGC_WANTCHARS.
I need WM_KEYDOWN/WM_KEYUP messages.
I need the up messages so I know when to turn notes off.
right now i got it covered by DLGC_ANY<whatever_that_was_called>
it stops the beeps.
when i get a tab or shift tab, I send the parent dialog the
message for next/prev control.
i never use arrow keys, but i suppose i SHOULD handle those, too.
not gonna bother with the mnemonic hoppin' biz
Anywayyyyyyyyyz, it's good enough i spose.
Thanks
...Steve
|
|
|
|
|
Hi I posted this question earlier too. I have a VC application runing fine on 2000 n XP . But I could't run that application on server 2003. So after trying everything , I just installed MS VC++ 6 on Server2003 and compile that application and ran it , and it ran fine.
But now I have to ran that VC application on another MS 2003 server , and even after copying the 2003 DLLs , its not runing. Do I have to install MS VC++ on that machine also to ran my application ???
Any solution ? suggestions ?? plz !
ZINC
|
|
|
|
|
Hello ZINC,
Your application has so many dependencies.
So first u have to find that all.
Or just making package. which is recommended by me.
Becoz as u said u copy all dll file's
but some dll file u have to register with os be regsvr32.exe command.
so by making package it will handle all that things for u.
Divyang Mithaiwala
with best regards
|
|
|
|
|
Hi Divyang ,
Thanks for reply , can you please guide me how to make package ?
Kind Regards,
Zinc
|
|
|
|
|
Hello zinc_z,
For making package first make exe file by building project.
then there is one tool
start->Program->Microsoft Visual Studio 6.0->Microsoft Visual Studio 6.0 tool -> Package & Deployment Wizard
|
|
|
|
|
hi there ,
i have checked this tool , this tool only give option to open VBP visual basic project. Mine is a Viusal C++ project.
Regards
ZINC
|
|
|
|
|
|
Hi Mike ,
I have done what u have sugested but still its not working !!!
anyother sugestions ???
Regards
ZINC
HELLO
|
|
|
|
|
Did you use dependency walker (As mentioned in the faq) and determine what dependencies your application is using? Most likely if it's a crappy MFC application and you're building debug you don't have the debug MFC binaries installed.
8bc7c0ec02c0e404c0cc0680f7018827ebee
|
|
|
|
|
I am getting the value as character , then i need to copy that character variable into another character pointer variable....can we do this.
char svr;
char* svr1;
How to assigh char to char*?
-- modified at 11:39 Friday 20th January, 2006
|
|
|
|
|
Hello satish,
first u have to allocate memory for svr1 pointer like.
svr1 = new char();
then u can just copy the value of svr to svr1 like
*svr1 = svr;
|
|
|
|
|
palakurthi satish wrote:
How to assigh char to char*?
svr1 = &svr; As others have suggested, you could allocate memory for svr1 , but for only one character, that is very inefficient/wasteful. What exactly are you trying to accomplish?
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
Hello,
I am using managed code to call a function in an unmanaged DLL. When I call the function, the program runs until the end of the function, and then gives a "Debug Assertion Failed!" dialog box for "Expression: _CrtIsValidHeapPoint(pUserData)". The error occurs no matter what code I have inside the function. For example, removing all the code in the dll function, so that it's just an empty function, does not prevent the error. The only thing that I've done to prevent the error is to comment out the line that calls the dll function.
This is how I import the function:
[DllImportAttribute("lib.dll")] extern "C" int func(string inputFileName);
This is the function declaration in the DLL code:
__declspec(dllexport) int func(string inputFileName)
Does anyone have any suggestions for how to track this down?
Thanks,
--Jordan
-- modified at 13:10 Friday 20th January, 2006
|
|
|
|
|
|
Even if I remove the whole function body, I get the same error. So, right now it looks like this:
__declspec(dllexport) int func(string inputFileName)<br />
{<br />
}
-- modified at 13:10 Friday 20th January, 2006
|
|
|
|
|
so, you're exporting a function that takes a std::string as input ? i suspect then that the std string ctor is going to be called even if there isn't any code in the body of the function. that could be related to the problem.
what if you change that to:
__declspec(dllexport) int func(const char *inputFileName)
{
}
?
Cleek | Image Toolkits | Thumbnail maker
-- modified at 13:15 Friday 20th January, 2006
|
|
|
|
|