|
Sorry, before I posted it I tried to search MSDN for the original code and no success, but I could not take the credits for a function I did not write.
I only tested it on Windows 2000, under NT style domains and Active Directories, but I think there's nothing tying it to Windows 2000, it should work on NT, too.
The way to go will be checking each function for Windows NT compatibility on MSDN.
My latest article:
SQL Server DO's and DONT's[^]
|
|
|
|
|
Hi,
I have an ATL which is creating a thread. This thread will have to send some messages.
I don't know exactly how to do it but I would like to create (I guess during the initialisation of my ATL) a window (which won't be visible) and which will receive the messages sent by the thread.
So here are my questions :
- How to create, without using MFC, a window in my ATL control.
- How to send a message from my thread that will be received by the window ?
Thank you for your help !
Jerome
|
|
|
|
|
|
I am having some troubles going about detecting when the user presses '^' (SHIFT+6). There aren't any virtual key codes for the shift+characters. I can dectect when the shift key is pressed but have problems after that. I tried checking to see if the lParam of the MSG structure was VK_6 but that just gave me an error saying VK_6 is an undeclared identifier (but to be honest, I don't the lParam was what I should have been looking at to start with).
This is the line code PreTranslating the shift key:
if( WM_KEYDOWN == pMsg->message && VK_SHIFT == pMsg->wParam )
Anyone got any suggestions to point me in the right direction. The fact that VK_6 is coming up undelcared leaves me at a loss. I'm starting to suspect that the shift+[key] are VK_UNDEFINED which is really going to suck. I will also be needing to get the '@'.
---------------------------------------------
The greenest grass is NOT on the other side of the fence, its the grass you take care of. Have you watered your lawn lately?
- Just remember when you point a finger at someone else, you are only one finger away from making a fist to hit them with!
If they don't get the basic research and learning skills down then they'll end up having a very hard life (Either that or they'll become managers) - Micheal P Butler <
|
|
|
|
|
Do you *need* to detect it in PreTranslateMessage ? Will OnChar do, or OnKeyDown ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Actually, OnChar or OnKeyDown would be fine as well. Was having problems getting the '^' detected (ASCII 0x5E). I knocked this out. A little clumsy but does the job. What I'm doing is dis-allowing the '^' as valid input as I have device that uses that uses the character internally so allow the user to type that into the data going in will cause problems. Basically I was thinking that I would send out a MessageBox each the user hit one of the invalid keys reminding them what they can't use and returning the edit at the same location that the char was typed (minus the char of course). This works but as I said, its clumsy - I was more looking to get something working in a hurry so I could move on with it working:
<br />
BOOL CRHTC100Dlg::PreTranslateMessage(MSG *pMsg)<br />
{<br />
if( WM_KEYDOWN == pMsg->message && 0x36 == pMsg->wParam && m_nShiftFlag )<br />
{<br />
return TRUE;<br />
}<br />
else;<br />
if( WM_KEYDOWN == pMsg->message || WM_KEYUP == pMsg->message)<br />
if(VK_SHIFT == pMsg->wParam)<br />
m_nShiftFlag = 1;<br />
else<br />
m_nShiftFlag = 0;<br />
return( CDialog::PreTranslateMessage( pMsg ) );<br />
}
I'll likely take a stab using OnKeyDown (if I can detect the '^') as it should save me from have to go back and remove the char and adjust the cursor postion. How was the weekend?
[edit]I just figured that using PreTranslateMessage was going be the least amount of effort on my part but I mis-guessed on that considering the difficulty it gave me (twenty minutes on that was at least 15 to many).[/edit]
---------------------------------------------
The greenest grass is NOT on the other side of the fence, its the grass you take care of. Have you watered your lawn lately?
- Just remember when you point a finger at someone else, you are only one finger away from making a fist to hit them with!
If they don't get the basic research and learning skills down then they'll end up having a very hard life (Either that or they'll become managers) - Micheal P Butler <
|
|
|
|
|
In OnChar, the first parameter is a UINT. If you declare a char to be equal to that value, you can test for any key you like:
<br />
void CTestView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)<br />
{<br />
char c = nChar;<br />
CString s(c);<br />
AfxMessageBox(s);<br />
}<br />
This will bring up any key you press in a message box.
The conversion from int to char is implicit.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Mel Feik wrote:
I'll likely take a stab using OnKeyDown
WM_KEYDOWN sends a VK code, but WM_CHAR sends the actual char, from what I can tell. I am using MFC7 ( and that means adding message handlers manually BTW ), but I think the wParam value in WM_CHAR will work the same as the UINT in my code sample.
Mel Feik wrote:
How was the weekend?
Parts were great, parts were awful. The average of all tabulated values is probably 'fair to middling'. I saw you were working ? Is my code working for you yet ?
Mel Feik wrote:
I just figured that using PreTranslateMessage was going be the least amount of effort on my part
I am sure WM_CHAR will work easily. I always try to avoid PreTranslateMessage if I can.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Christian Graus wrote:
I saw you were working ? Is my code working for you yet ?
Nope... I am supposed to have my CD's back for my enterprise/architect back tomorrow by 4 pm. Had to have my brother overnight it to me Saturday. I'm looking forward to, it been rough not being able to do certain things on this SE version. Been challenging though.
---------------------------------------------
The greenest grass is NOT on the other side of the fence, its the grass you take care of. Have you watered your lawn lately?
- Just remember when you point a finger at someone else, you are only one finger away from making a fist to hit them with!
If they don't get the basic research and learning skills down then they'll end up having a very hard life (Either that or they'll become managers) - Micheal P Butler <
|
|
|
|
|
The VK code for '6' is the same as the ASCII char value; to check for the Shift key being pressed you could GetKeyState() function (GetKeyState(VK_SHIFT)).
Regards,
Cosmin
|
|
|
|
|
How to display it? I called SetButtonText, but nothing was changed...
|
|
|
|
|
Try CWnd::SetWindowText (or something like that, I don't remember exact name)
|
|
|
|
|
I am just trying to launch a simple thread. Code compiled with no error but the thread function is simply NOT invoked for some reason!
And i checked the thread handle - hThread - It's NOT NULL!! I cant see why it doesnt invoke the thread function!
Here's the code fragment:
// TryThreading.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream.h>
#include <windows.h>
DWORD WINAPI SomeThreadFunc(void* pParam)
{
DWORD dwRetCode;
cout << "Thread Func invoked!" << endl;
if(pParam!=NULL)
{
cout << "nNum= " << * (int*) pParam << endl;
}
return dwRetCode;
}
int main(int argc, char* argv[])
{
HANDLE hThread = NULL;
int nNum = 0;
unsigned long nID = 0;
hThread = ::CreateThread(
NULL,
0,
(LPTHREAD_START_ROUTINE) SomeThreadFunc,
(void*) &nNum,
0,
&nID
);
CloseHandle(hThread);
return 0;
}
HelP!
norm
|
|
|
|
|
Your primary thread returns from main() right away, and that makes the whole process close. The thread is being started, the app just closes right away so you never see the output from the thread.
--Mike--
Thing #9 to say when mad at work: "Therapy is expensive. Popping bubble plastic is cheap. You choose."
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
oh my god. I am such an idiot!
norm
|
|
|
|
|
just want to thank u one more time!
i looked at the damn code for like 3 hours!
norm
|
|
|
|
|
who can tell me?
thanks!
-----------------------------
Mr.Whelk
-----------------------------
Zhuhai City ,Guangdong ,China
|
|
|
|
|
I don't know if it is possible in ADO, you need to get the IJetCompact interface and call its Compact method. It is dead easy using OLE DB:
<br />
CDataSource src;<br />
<br />
CComPtr<IJetCompact> spCompact;<br />
hr = src.m_spInit->QueryInterface(IID_IJetCompact, (void **) &spCompact);<br />
<br />
CDBPropSet init(DBPROPSET_DBINIT);<br />
init.AddProperty(DBPROP_INIT_DATASOURCE, "compacted.mdb");<br />
<br />
hr = spCompact->Compact(1, &init);<br />
|
|
|
|
|
i use msado15.dll to operate database in ado
can you tell me how?
-----------------------------
Mr.Whelk
-----------------------------
Zhuhai City ,Guangdong ,China
|
|
|
|
|
You can use CDaoDatabase from MFC to do it easily enough. Not sure about ADO though
-Alex
|
|
|
|
|
we want to use ado to realize the popose
-----------------------------
Mr.Whelk
-----------------------------
Zhuhai City ,Guangdong ,China
|
|
|
|
|
Hi
can anybody guide me to load Toolbar dependent bitmaps in my popup menu which will appear on RButtonclick on a DialogBox(or Bitmap) in a Formview.will be so thankful if you give me
the code.
thanks and regards
ThomasKennedyBose
|
|
|
|
|
Can any body help me i'm try to create in CDocument view an Rich edit control that will that will allow me have a line count on the side when the user type any thing into the edit. Also beside the CRichEdit I want the color to be gray and white for CRichedit. SO i kind of looks like Visual Studio Editor or any coding editor.
Can anybody help me to get this going.
Thanks alot.
|
|
|
|
|
This is probably a stupid question (I haven't had much sleep in the past 3 days).
How can I tell Visual C++ to perform an extra step when compiling each .cpp file. What I want to do is basically what BoundsChecker does when you perform a compile. You see "compiling something.cpp" followed by a line reading "instrumenting something.cpp".
I know about custom build steps but I can't seem to get this to do what I want???
|
|
|
|
|