|
CEdit m_Edit;
m_Edit.Create(ES_NUMBER|WS_CHILD|WS_VISIBLE|WS_BORDER,CRect(0,0,100,23),this,1);
m_Edit.SetWindowText("123");
----------------------------
m_Edit.ModifyStyle(0,ES_NUMBER);
or
change Number (ES_NUMBER) to true in window property form your Editbox
|
|
|
|
|
Hi,
I need to have a my C++ service detect keyboard clicks to perform certain actions.
I managed to create a dll to hook those events as described in: http://www.codeproject.com/win32/overrideparams.asp
BUT, it only detects clicks in the console session, not from a terminal session.
I even tried to enumerate all the windows stations and their desktops and run the InstallHook function on all of them... but no luck.
Any ideas ? I searched what seems to be the entire web... I'd appreciate any samples or pointers... seems like it should be fairly simple to do.
Thanks,
Ben
|
|
|
|
|
What type of hook did u put? WH_SHELL
Try putting a WH_KEYBOARD hook
nave
|
|
|
|
|
Yes, I put in a WH_KEYBOARD hook... but doesn't work if I'm in a TS session. (if I TS to the console session using mstsc.exe /console then it does work, but not in a normal TS session).
Code in DLL to install the hook is as follows:
hHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, hInst, 0);
return (hHook != NULL);
I tried with both hHook being in a shared data segement and not...
In my C++ service, I call the code as follows (I also tried enumerating all the winstations and desktops and running InstallHook on all... but no luck):
/* -- Open user's window station "WinSta0". -- */
HWINSTA hWinStaUser = OpenWindowStation("WinSta0", FALSE, MAXIMUM_ALLOWED);
/* -- Set process window station to "WinSta0", this enables the process to
access objects in the window station such as desktops. -- */
if (SetProcessWindowStation(hWinStaUser)) {
/* -- Open user's desktop "Default". -- */
HDESK hDeskUser = OpenDesktop("Default", 0, FALSE, MAXIMUM_ALLOWED);
/* -- Set thread desktop to "Default". -- */
if (SetThreadDesktop(hDeskUser)) {
/* -- Now install hook procedure to monitor events associated
with threads in the user's desktop. -- */
InstallHook()
etc...
|
|
|
|
|
I found the solution, which was in some other part of my code, I need to call Default() to force the drawing of the "inside" before drawing the border.
I'm trying to draw a border around a CEdit derived control.
The CEdit has the "Vertical Scroll"
void CMyEdit::OnNcPaint()
{
Default();
CDC* pDC = GetParent()->GetDC();
CRect screenRect;
GetWindowRect( screenRect );
ScreenToClient( screenRect );
CRect newRect;
newRect = screenRect;
ClientToScreen( newRect );
GetParent()->ScreenToClient( newRect );
pDC->FrameRect( newRect, &m_BorderBrushFocus );
newRect.DeflateRect( 1, 1, 1, 1 );
pDC->FrameRect( newRect,&m_BorderBrushFocus );
}
When doing this, it draws the frame around the CEdit, but it hides the vertical scrollbar; when I start typing in the edit box, the "shape" of the scrollbar is visible, and if I add enough text to enable the scrollbar, it appears; but only if no repaint is necessary, then it will be erased.
Am I allowed to draw in such fashion ?
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
-- modified at 16:00 Monday 8th May, 2006
|
|
|
|
|
yes it hides the vertical scrollbar when type,but
can you tell please why use OnNcPaint instead WM_PAINT ?
|
|
|
|
|
I'm trying to put up a waitcursor before a possible lenghty operation (CSocket connect, if timeout occurs),but i'm unable to put it up. The waitcursor flashes real fast and returns to the standard
pointer, and after some debugging, it looks like the CSocket.connect function disengages
the wait cursor (as a test I removed csocket connect, and put a sleep in there and wait cursor stayed up for the duration).
I have tried different variations of putting up the wait cursor (CWaitCursor, beginwaitcursor, loadCursor) and at different parts of the code, to no avail.
Any help would be greatly appericated.
Thanks
|
|
|
|
|
Some other window has responded to the WM_SETCURSOR message. If you are doing this socket communication in a separate thread, a "wait" cursor is not required.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
If I set a breakpoint before I do my socket connect, and then continue my waitcursor shows up, if I run it w/o any breakpoints, no waitcursor!
Another weird thing is, the same function is called from another dialog, and the waitcursor shows up like it is supposed to.
|
|
|
|
|
All CWaitCursor does is call SetCursor() once. If your code ends up pumping messages and receives a WM_SETCURSOR which it does not handle, DefWindowProc() will set the cursor back to the cursor specified in the window class. It sounds like this is what's happening in your app. You'll need to handle WM_SETCURSOR and keep a flag saying whether you want the hourglass cursor, and set the cursor appropriately in your WM_SETCURSOR handler.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Have you tried BeginWaitCursor and EndWaitCursor .
Nibu thomas
Software Developer
Faqs by Michael dunn
|
|
|
|
|
Yup, I have tried BeginWaitCursor(), EndWaitCursor(), I put in a message handler for WM_SETCURSOR, but again, the wait cursor shows up when I call my function from one class, but not when I call it from another, and they are both going to the same place. And yes if I put a breakpoint before my lengthy operation and then it shows up.
Thanks
|
|
|
|
|
Hi All,
I have wireless application which has socket connection for the data transfer. In windows XP SP2, i add the application into firewall exception list. But in windows 2000 i have problem to add it into that list. Please help me ....
Thanks and regards
Mahesh Patil
|
|
|
|
|
Dear all,
I have implemented an IE in an mfc application (using the microsoft webBrowser).
I need to detect the position where a user clicks (x and y coordinates).
How do i do that ?
thanx
llp00na
|
|
|
|
|
You need to use the COM interface to the Document Object Model and susbscribe to events. The event notification data will contain the x,y coordinates
Start Here[^]
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
thanx for your reply,
I have been looking at that article before. But i thought that this way will only allow me to identify which html element the user clicked, it does not specify the exact (x,y) of user clicks.
m I wrong ???
llp00na
|
|
|
|
|
When you receive an event you can use the IHTMLEventObj family of interfaces to get all kinds of information on the event.
Steve
|
|
|
|
|
llp00na wrote: I need to detect the position where a user clicks (x and y coordinates).
How do i do that ?
By responding to the WM_LBUTTONDOWN and/or WM_MOUSEMOVE message(s).
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
can you please point out any articles ?
thanx
llp00na
|
|
|
|
|
See here.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
thanx,
sorry for my novice questions. How can i add the message WM_LBUTTONDOWN to my application so that every time the users clicks the left menu i retrieve the message ???
llp00na
|
|
|
|
|
llp00na wrote: How can i add the message WM_LBUTTONDOWN to my application...
ClassWizard (Ctrl+W).
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
Nothing happens when i press ctrl+w on the class view. I am using visual studio 2003.
llp00na
|
|
|
|
|
llp00na wrote: I am using visual studio 2003.
It helps to mention this sort of thing up front. See here.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
I am sorry david. it wont happen again.
I have done what you advised. I have got a new message event handler for the click down button. However it does seem to work at all. I have tried printing out some statements there but none is shown up !!!
llp00na
|
|
|
|