|
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
|
|
|
|
|
The line
ppCrypt->Release();
should read
ppA->Release();
Thanks for the help,
Bill
|
|
|
|
|
I am trying to play around with an object library. Started looking at it in VB for simplicity. When I imported the type library using class wizzard to create wrappers only a few objects were inserted, when there are tons in VB object browser. Another thing I noticed when i tried to use VBs late-binding using 'createobject' i couldn't access these objects either.
Anyone any clues why I am having trouble accessing these objects from a type library, thats fine when used as a reference in VB?
Cheers
Rich
|
|
|
|
|
Hey all,
i have all these hexadecimal values(at least i think they are hexadecimal hehe) like this:
74 03 00 00 83 5b 83 8e 6d
etc...
now when you see these characters in notepad some are just blanks.
My question is, how can i make a char that contains a string for example with the hexadecimal values i just gave?
And is there an easier way then to add one character at a time because i have to make a string thats about 90 of those so it would be usefull
Thanks!
Kuniva
--------------------------------------------
|
|
|
|
|
They certainly look like hexadecimal to me. How are the values stored?
--
Andrew.
|
|
|
|
|
well they are stored binary in a file, but i dont want to extract it from there because its only a piece of it and the positions change etc... i just want to build the string from code, that has to be possible no?
Thanks
Kuniva
--------------------------------------------
|
|
|
|
|
use an ifstream to read the values and an ostringstream to build a string out of them. I have some articles on fstreams and ostringstream on CP.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|