|
Well, it is still possible to see that the user tried to select an item, thank you the same.
rui
|
|
|
|
|
Hello,
i wrote an mdi-app with c++/mfc under winnt 4.0. When logging off the current user from winnt, winnt closes all running apps before the login-dialog will be displayed. This works correct for all apps i tested, but when winnt wants to close my app before logging off, the explorer crashes. it seems that the app closes the right way, because no debug-message created by my app is missing in the corresponding debug-file. Where is the difference between closing an app by hand and closing an app automatically by winnt before logging off ? And why can my app cause the explorer to crash ? Please help me, i don't know a way to fix this
Best regards
tabor25
|
|
|
|
|
You might want to try handling the messages WM_QUERYENDSESSION and WM_ENDSESSION . They are sent to all running applications during the shutdown process.
Gary R. Wheeler
|
|
|
|
|
I have a static control with the bitmap style and the notify style set.
I have an on click handler as well
ON_STN_CLICKED(IDC_LANG, OnStnClickedStaticlang)
void CRegularDialerDlg::OnStnClickedStaticlang()<br />
{<br />
.....<br />
m_langstatic.SetBitmap(LoadBitmap(NULL,<br />
MAKEINTRESOURCE(IDB_BITMAP5)));<br />
.....<br />
}
Now as you can see the only thing I do is to change the bitmap [the rest of
the code has nothing to do with the static control]
Now my problem is that the on click does not work anywmore [as if it lost
the notify style bit somehow]
I used Spy++ and found that after one click it won't accept this static
control as a window (( [means I cant drag the cross and select this
control]
has anyone else encountered this issue? Is this some kinda bug?
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
You're passing NULL as 1st argument to ::LoadBitmap. ::LoadBitmap fails. CStatic::SetBitmap (which is just a wrapper over STM_SETIMAGE) gets NULL bitmap and sets the size of control to 0x0 pixels.
You need to pass AfxGetResourceHandle() to LoadBitmap, or, better yet, use CBitmap::LoadBitmap.
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|
|
Tomasz Sowinski wrote:
You're passing NULL as 1st argument to ::LoadBitmap. ::LoadBitmap fails
Hmmm. Tomasz, can you take a look at this URL :-
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_cstatic.3a3a.setbitmap.asp
and scroll down to the example :-
[I copy/paste below for your convenience]
Example
CStatic myStatic;
myStatic.Create(_T("my static"),
WS_CHILD|WS_VISIBLE|SS_BITMAP|SS_CENTERIMAGE, CRect(10,10,150,50),
pParentWnd);
myStatic.SetBitmap( ::LoadBitmap(NULL, MAKEINTRESOURCE(OBM_CHECK)) );
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Nish,
You seem to not believe in my explanation
Anyway, the LoadBitmap call with NULL in the example loads so-called OEM bitmap embedded in one of Windows modules. OBM_CHECK is special, predefined identifer. Obviously, you're loading your own bitmap, not the OEM one. That's why you need non-NULL as first argument to LoadBitmap call.
Read the LoadBitmap docs for more details.
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|
|
Tomasz Sowinski wrote:
You seem to not believe in my explanation
Nope, not at all, but I was confused about the sample
Who would dare disbelieve Tomasz
Tomasz Sowinski wrote:
Read the LoadBitmap docs for more details.
Yup, just read it and feel silly about not having done so previously
Thanks again, Tomasz!
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
In the program the following code prints the symbols corresponding to the data array:
for (WORD i = 0; i <65536; i ++)
{
CString str = (TCHAR) i;
int x =...;
int y =...;
pDC-> TextOut (x, y, str);
}
On Windows98SE the string will be transformed in ANSI
Whether it is possible on Windows98 to display Unicode. If yes, as it to make (and if it is possible with a small example)
Best regards,
Eugene Pustovoyt
|
|
|
|
|
|
Thank you!
Following code is work on Win98:
WCHAR chSymbol[] = {nValue};
::TextOutW(hDC, x, y, chSymbol, 1);
Best regards,
Eugene Pustovoyt
|
|
|
|
|
Hello!
How can I pass a pointer for a class correctly to a CWinThread derived class?
I've got the pointer global decleared as
CMyThread* pThread;
CComPort* pGSM = new CComPort();
and when I start the workerthread I pass along the pointer like this
<br />
void CMyView::OnStartThread()<br />
{<br />
extern CMyThread* pThread;<br />
extern CComPort* pGSM;<br />
<br />
if (NULL != (pThread = new CMyThread()))<br />
{<br />
ASSERT_VALID(pThread);<br />
pThread->m_pThreadParams = NULL;<br />
pThread->m_pMainWnd = AfxGetMainWnd();<br />
pThread->m_hWnd = this->GetSafeHwnd();<br />
pThread->pGSM = pGSM;<br />
pThread->m_hMutex = CreateMutex( NULL, FALSE, NULL );<br />
if (!pThread->CreateThread(CREATE_SUSPENDED))<br />
{<br />
delete pThread;<br />
return;<br />
}<br />
VERIFY(pThread->SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL));<br />
pThread->ResumeThread();<br />
}<br />
<br />
return;<br />
}<br />
The application works on some computers, but on others it can halt or even show diffrent status on a bool returned from pGSM.
Thanks,
Floppe
|
|
|
|
|
There's nothing wrong in passing a pointer to a thread the way you're doing. What I think could be causing your problem is that you set pThread->pGSM after the thread has started, which opens the possibility that the thread is trying to access the pointer before it is pointing to where it should.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
PS: Excuses, you're not starting the thread before setting its parameters, so the problem must lie somewhere else.
|
|
|
|
|
Thanks for the quick answer.
I had cut out a little too much from my function in the first post, so I modified it.
I still think there's something wrong with it, because my function pGSM->Initialize() uses ReadFile() to open the serial communication port and iPAQ hangs on ReadFile when I execute it from the workerthread but works if I execute it from the mainthread.
And as I mentioned ... pGSM->IsConnected() returns a BOOL and the workerthread returns correct value, but the mainthread can sometimes return wrong value.
// Floppe
|
|
|
|
|
How does CComPort work internally? I once tried similar things with CAsyncSocket related stuff, and it consistantly screwed up because of the way CAsynCsocket handles messages internally.
I got it working by starting the thread suspended, detaching a handle from the socket, passing the handle to the thread, and then starting the thread. upon start, the thread attached the socket handle to a new CASyncSocket.
COuld it be that CComPort behaves similarly?
STL is a religeon. Enquiries to Reverend Christian Graus
|
|
|
|
|
As a rule, any MFC object that uses one of the MFC maps (especially the message map), cannot be shared between threads (since threads have separate message queues). You have to pass handles between threads.
Gary R. Wheeler
|
|
|
|
|
This should be a simple question... I have an edit box (with the 'password' style set in my resource file) in a dialog that I'd like to use to display either passwords (******) or normal, readable text. I need this behaviour to change dynamically. I tried adding/removing the ES_PASSWORD style from the control, but that didn't work. The edit box still displayed asterisks. How can I get the desired result?
Thanks!
|
|
|
|
|
SendMessage(hEdit, EM_SETPASSWORDCHAR, 0, 0); Sprudling
|
|
|
|
|
Hello,
I would like to monitor any file and directory changes in a removable
device (memory card reader). However, when I create the handle of the drive
it failed.
HANDLE hDir = CreateFile(
"g:\\", // G: is the USB memory card reader
FILE_LIST_DIRECTORY,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED,
NULL
);
Can I monitor removable device with ReadDirectoryChangesW? If so, how
do I create the handle of that device?
Thanks!
|
|
|
|
|
Synopsis: crash when run only with breakpoint (no crash if directly run), when there are no prexexisting keys in the registry for the app:
I traced the app to the last closekey where it crashes the hKey3:RegCloseKey(keyHandle3); Initially there are no keys in the registry and OpenKeyEx doesnt make them either. How come this isnt a problem when running without breakpoints (same exact scenario - no keys in registry)?
the values of LONG res = RegOpenKeyEx(keyHandle1, "MyCompany4", myApplication , are 2 and 6 - non success error codes. So should I put my RegQueryValueEx in a big if statement executed only ifOpenKeyEx is successful?
Apparently it doesnt like closing if it didnt open them (they werent present). So the closes should go into the if too, dependent on value of res(not result but res). Is this a sound idea?
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CMDIFrameWnd::PreCreateWindow(cs) )
return FALSE;
cs.cy = 600;
cs.cx =800;
HKEY keyHandle1, keyHandle2, keyHandle3;
CString str;
DWORD valType;
DWORD xpos, ypos;
DWORD width, height;
DWORD valSize = sizeof(DWORD);
RegOpenKeyEx(HKEY_CURRENT_USER, "Software",
0, KEY_ALL_ACCESS, &keyHandle1);
LONG res = RegOpenKeyEx(keyHandle1, "MyCompany4",
0, KEY_ALL_ACCESS, &keyHandle2);
res = RegOpenKeyEx(keyHandle2, "MyApplication4",
0, KEY_ALL_ACCESS, &keyHandle3);
RegQueryValueEx(keyHandle3, "XPosition",
0, (LPDWORD) &valType, (LPBYTE) &xpos,
(LPDWORD) &valSize);
RegQueryValueEx(keyHandle3, "YPosition",
0, (LPDWORD) &valType, (LPBYTE) &ypos,
(LPDWORD) &valSize);
RegQueryValueEx(keyHandle3, "Height",
0, (LPDWORD) &valType, (LPBYTE) &height,
(LPDWORD) &valSize);
LONG result = RegQueryValueEx(keyHandle3, "Width",
0, (LPDWORD) &valType, (LPBYTE) &width,
(LPDWORD) &valSize);
if (result == ERROR_SUCCESS)
{
cs.cx = width;
cs.cy = height;
cs.x = xpos;
cs.y = ypos;
}
RegCloseKey(keyHandle1);
RegCloseKey(keyHandle2);
RegCloseKey(keyHandle3);
handles 1 and two dont complain on closing...
|
|
|
|
|
yuck.
have you considered using one of the many registry wrapper classes available here on CP ? they can get rid of all of that open/close hassle and they can really clean up your code. i'll never use the registry APIs again.
-c
"I am angry that so many of the sons of the powerful and well-placed... managed to wangle slots in Reserve and National Guard units...Of the many tragedies of Vietnam, this raw class discrimination strikes me as the most damaging to the ideal that all Americans are created equal and owe equal allegiance to their country."
--Colin Powell
|
|
|
|
|
|
You have now learned why you need error checking. You can look at ATL::CRegKey or any of the registry wrappers here for guidance on how to write the error checks.
--Mike--
Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I have a work assignment wherein I have to create a COM object to contain another COM object. The inner object was not aggregatable or poolable on Win2K server, so we needed to wrap it. I'm to the point where I need to pass the function calls to the contained object. My problem is that I can't get an interface pointer to the inner objects custom interface. How would I go about this? I tried creating an IID using the value the inner object registered in the registry, but I keep getting compiler errors when I try that.
How can I create a variable of the type of the inner object's custom interface since I don't have any source/headers for this object (I do have the IDL and the DLL, of course, but that's it).
Time is of the essence here! I'm stuck!
Thanks in advance.
|
|
|
|
|
import the .dll and use the CreateInstance method.
Say the interface is named X.A
#import X.dll no_namespace
IAPtr ppA;
try {
CoInitialize(NULL);
ppA.CreateInstance(__uuidof(A));
ppA->Somemethod();
ppCrypt->Release();
CoUninitialize();
Thanks for the help,
Bill
|
|
|
|
|