|
Jim Crafton wrote:
Curiously, I just walked over to the one of the machines and opened regedit and I saw a number of DLLs under the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\KnownDLLs key but NOT msvcrt.dll - is this one hardcoded somewhere else I wonder ?
Oh sorry - I was not able to check this (no NT4 box available here ).
AFAIR (it's some time ago I struggled about this topic) the "know-dll" property is a transitive property. This means, that every DLL that is implicitly loaded from a known-dll is also treated as known-dll (The whole mechanism is for stability purposes, so this makes sense). I simply assume that some of the DLLs imports msvcrt.dll.
Hm...
I just checked it on my XP box. Using the "WinObj" tool from http://www.sysinternals.com[^] you can view all dlls that are actually treated as a known dll (also the imported ones). And I had to find out that even on XP msvcrt.dll is a member of this list
Obviously you just not ran into problems on Win2k and above, because it is shipped with a newer version of msvcrt.dll. Your side-by-side copy has never been loaded on any version of NT, it is just wasting disk space...
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
Hi all,
I am learning window programming.
I want to draw text when my mouse moves on client rectangle.
I have two alternatives to choose from
1. TextOut
2. DrawText
Which one should I use and why?
I try with the simple test code using TextOut to draw text at point(10,30) on client rect
But I don't get it work.
the code is as follow:
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ;
TCHAR szBuff[10] = "Hello";
switch (message)
{
.....
case WM_MOUSEMOVE:
hdc = BeginPaint (hwnd, &ps) ;
TextOut (hdc, 10, 30, szBuff, lstrlen(szBuff));
EndPaint (hwnd, &ps) ;
return 0 ;
..........
}
}
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("HelloWin") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindow (szAppName, // window class name
TEXT ("The Hello Program"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL) ; // creation parameters
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
Once I get the above code to work then I would like that text "Hello" is followed when I move my mouse on the client area.
I would appreciate if you could give my a sample code for that or any suggesion.
Thanks in advance
regards
/rsasalm
|
|
|
|
|
Hi,
OK your first problem is here
case WM_MOUSEMOVE:
hdc = BeginPaint (hwnd, &ps) ;
TextOut (hdc, 10, 30, szBuff, lstrlen(szBuff));
EndPaint (hwnd, &ps) ;
return 0 ;
You should NEVER use BeginPaint() /EndPaint() outside of a WM_PAINT message
To get the dc do this:
HDC hdc = GetDC( hwnd );
//do painting
//release the DC
ReleaseDC( hwnd, hdc );
Try this it should fix the TextOut call
the diff between the two is in hte kinds of formatting options - also one will draw tab characters (and interpret them properly) while the other simply draws them as a glyph (which is why you'll see a big square character anywhere you have \t, \r, \n, etc
|
|
|
|
|
Hi Jim,
Thanks for reply.
Now Drawing text "Hello" at (10, 30) works.
I hope someone can answer my next question
i.e. drawing text "Hello" when moving curor on
client rect.
thanks
/rsasalm
|
|
|
|
|
A couple pointers:
- It is always a good idea to do all your drawing in your WM_PAINT handler, that way any drawing that you do is not lost when the window recieves a WM_PAINT message.
- If you are using TCHARs for strings, use the _tcs* functions (defined in tchar.h)
That said, what you should do is have to variables that store the coordinates where you want the string to be drawn. In your WM_MOUSEMOVE handler you change the values to the new coordinates, and then call RedrawWindow().
int x = 0, y = 0;
...
case WM_MOUSEMOVE:
x = LOWORD(lParam);
y = HIWORD(lParam);
RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW);
break;
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps);
TextOut (hdc, x, y, szBuff, _tcslen(szBuff));
EndPaint (hwnd, &ps);
break;
...
<Edit - fixed syntax error in RedrawWindow call>
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
Hi again,
Thanks for reply and now moving cursor with text "hellow" works fine.
I have one more question.
I found a function "GetCurrentPositionEx" with the following documentation:
*********************************
The GetCurrentPositionEx function retrieves the current position in logical coordinates.
BOOL GetCurrentPositionEx(
HDC hdc, // handle of device context
LPPOINT lpPoint // address of structure receiving current position
);
********************************
From documentation it seems to me that I could find the position of cursor as below:
case WM_LBUTTONDOWN:
POINT pt;
hdc = GetDC (hwnd) ;
GetCurrentPositionEx( hdc, &pt);
x = pt.x;
y = pt.y;
break;
But it doesn't work.
Am I missing something?
thanks for help
regards
/rsasalm
|
|
|
|
|
GetCursorPos() is used to get the current mouse cursor position on the screen.
GetCurrentPositionEx() is used to get the current text output position as set by TextOut() or ExtTextOut() after a call to SetTextAlign(hdc, TA_UPDATECP)
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
how can i read barcode (or in general, port data) using c/c++?
thankx.
|
|
|
|
|
Did you try searching for "barcode" first? No, of course not. There is a series of articles that deal with it.
|
|
|
|
|
A CP sample has:
BOOL CADOTestDlg::DestroyWindow()
{
if ( (m_pConn->State & adStateOpen) == adStateOpen)
m_pConn->Close();
CoUninitialize();
return CDialog::DestroyWindow();
}
If I wanted to close in case the conn was open, I would just do:
if ( (m_pConn->State == adStateOpen)
m_pConn->Close();
Why do we have the & there? I tried to look up State on the MSDN but it didnt point me to the Connection State. For that matter doing F1 on Connection didnt land me in any databasey link either.
So I assumed State is the property which holds a particular value like open or closed or whatever.
So why do we have (m_pConn->State & adStateOpen) == adStateOpen
Thanks,'
ns
|
|
|
|
|
ns wrote:
So why do we have (m_pConn->State & adStateOpen) == adStateOpen
testing for a bit mask
|
|
|
|
|
it's a bitwise-AND it takes the bits from the left side and the bits from the right side, lines them up and does an AND on each pair.
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
I read about & and understand the math operation, but I'm trying to figure out in English what it accomplishes, if its possible.
Like if the right side is 010101, and the left side is 111111, then the result of & is 010101. This can also result from the left side being 01101 and many other such combinations. I just dont understand what it means. I dont even know if I should try....
Aaargh!
ns
|
|
|
|
|
it means that m_pConn->State can be in more than just the "open" state at any time.
imagine m_pConn->State = 010101 and adStateOpen = 000100. your test: m_pConn->State == adStateOpen will fail, because m_pConn->State is actually in two other states besides the "open" state. the "&" test knocks out all bits except the one representing the "open" state, before testing.
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
Many thanks! Precisely the sort of answer I was needing - its clear now!
Appreciate your help,
ns
|
|
|
|
|
It's checking if a specific bit is set.
In the following example, uMask can hold up to 32 distinct flags (since it's a 32 bit quantity). To check if bit 2 (i.e. decimal value 4) is set, we do:
unsigned long uMask = ...;
unsigned long uTest = 0x04;
if (uMask & uTest) {
printf ("Bit 2 is set");
}
You wouldn't want to simply compare uMask with uTest using the == operator, because that simply tests if they are identical. So in your ADO example (btw I know nothing about ADO), you're checking if the connection happens to be open. If so, you're closing it.
You could write a function to do this check, thereby making the code more readable and maintainable. For example:
bool isAdoConnectionOpen
(CAdoConnection* pConn)
{
ASSERT (pConn != NULL);
return ((pConn->State & adStateOpen) == adStateOpen)
}
You'd use the function in this manner:
if (isAdoConnectionOpen (pConn)) {
pConn->Close();
}
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
In addition to what others have said:
This construct also checks for multiple bits (ie adStateOpen is a combination of bits)
11001111 - State
& 01000100 - adStateOpen
----------
01000100 - result == adStateopen
and
00001111 - State
& 01000100 - adStateOpen
----------
00000100 - result != adStateOpen but is not false either
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
I have to develop an application in Visual C++
that must connect itself to any type of LAN in order
to open a shared database.
This application must run on Win2K.
It can be not foreseen if the remote PC, where
the database is stored, manages a work group,
a domain or other rules.
I only know that the database is contained by a shared
folder.
What have I to foresee in my application ??
Which services or protocol have I to install in my PC ??
|
|
|
|
|
Hello all,
I've been reading the MSDN library stuff to try to figure out how GetActiveDocument works and I can't figure it out.
I have a string in my CDocument class called m_Filename.
I can access this variable in my View class with a GetDocument like this
CDisplayDIBDoc* pDoc = (CDisplayDIBDoc*)GetDocument();
if (pDoc)
{
(LPCTSTR)pDoc->m_Filename);
}
So I want to access this same variable in my CMDIChildWnd class that I made.
And I did this
CDisplayDIBDoc* pDoc = (CDisplayDIBDoc*)GetActiveDocument();
if (pDoc)
{
(LPCTSTR)pDoc->m_Filename);
}
Assuming it would work the same. I didn't override GetActiveDocument. Should I have?
I also rechanged that code with a !pDoc and a AfxMessageBox, and voila, the Message Box shows up, which means that I KNOW that pDoc is returning as a NULL.
How can I get to my m_Filename (a CString) variable in my Doc class from tmy CMDIChildWnd class?
Thanks a bunch
|
|
|
|
|
Here is the magic bullet I found works:
CTtDoc *pDoc=(CTtDoc *)((CMainFrame *)AfxGetApp()->m_pMainWnd)->GetActiveFrame()->GetActiveDocument();
It came from a discussion on these message boards just a few days ago.
In your case, you can then access, of course, by:
pDoc->m_Filename
Good luck!
JennyP
|
|
|
|
|
Ok so I tired it like this:
CMyDoc *pDoc = (CMyDoc *)((CMainFrame *)AfxGetApp()->m_pMainWnd)->GetActiveFrame()->GetActiveDocument();
if(pDoc)
{
pDoc->m_Filename;
}
And this doesn't work.
I put
if(pDOc == NULL)
{
AfxMessageBox("pDoc is NULL");
}
and this worked, so pDoc is still Null and not the String in m_Filename
So either the string in m_Filename gets erased somewhere and set back to NULL, or I am doing something still wrong.
Any ideas?
NickOne
|
|
|
|
|
Hello again,
Well I tried the code that I wrote above in a Dialog Window class that I added to the project.
In the Dialog window, it works correctly. Everytime, the m_Filename is accessed correctly.
BUT, in the CMDIChildWnd class that I added, it still shows up as a NULL. Why would this be??
i am really lost on this, and I really want to figure this out.
Thanks,
Nick
|
|
|
|
|
Dear memebers,
I'm searchnig for a source code of a "dwonload manager" program with pause/resume and multipart download capabilities.Please help me if know konw
any open source program in C/C++ or any document that could help me
thank you in advance
|
|
|
|
|
I have a .cpp file that compiles fine when used in a console app but gets errors when I include it in a MFC App.
d:\Visual C++.NET In 21 Days\Day 06 Dialogs\CMatrixTest.cpp(588): fatal error C1010: unexpected end of file while looking for precompiled header directive
I look up error 1010 and I get the increadibly useful result "The configuration registry key is invalid."
The file consists of a class definition that uses the standard template library. No main() or WinMain() function. I haven't included it yet in any other files.
Anyone have a clue as to what's going wrong because I sure don't.
|
|
|
|
|
Raskolnikov,
I've had problems with a similar message before. Go to the offending file and delete any and all characters at the end after your last statement. When I have done this, it usually clears it up.
Good luck!
Rich
|
|
|
|
|