|
Actually, I had noticed that, especially since I had just encountered a CWnd pointer like that in my program and I put in special logic to test for 0xcdcdcdcd. I was being methodical about the problem so that is why I started out by asking what is "state"? Your answer is also good, since it seems that your answer did not require a reply. I do not know what I was thinking, but I guess I needed more information before I could help. Perhaps I just got distracted by confusion about the rest of the question and forgot to mention about the 0xcdcdcdcd stuff, so it is good you caught it.
|
|
|
|
|
That's exactly the problem. I discovered it last week, but didn't post it. (I guess I should have.)
Thanks for your help.
Stephanie
|
|
|
|
|
Hi,
I've a problem in handling the Event Sink of a activeX control, which is created dynamically in the code.
I created a MDI application, in that on the MDIFramewnd's Oncreate function I created a 3'rd party ActiveX control with it's parent as the MDIFrameWnd. To handle the ActiveX events i created the Event Sink macro's
manually. But it seems that it is not calling the events in my MainFrame implementation. How can add a event handler for the activeX control. Please help me.
Advance thanx,
Subbi.
|
|
|
|
|
I 'm programming about connect Outlook 2000 by vc++ and i will
get value from outlook (Meeting or calendar) and write to file and then
i will import file to outlook . Now i meet some problem about time this it
set. When i get meeting of 15 June 2000 from outlook 2000 and write to file,
and then i import by read this file to outlook i have new nneting but this time of
meeting it 's not 15 June 2000 , but it is time now .
I worry about it very much
Please who have used or programming with file name msoutl9.cpp please tell me
or it have new file that 's not msoutl9.cpp Plese tell me .
|
|
|
|
|
Is it possible to use the word spell checker from a Visual C++ programm. Any samples?
thank's
Tom
|
|
|
|
|
Im working on a little program that does on command drawing
eventually plotting / cutting (Very lucky to have opportunity to experiment on high tech peice of machinary ) )I had a program thatused a CArray<cpoint,cpoint> collection but I need to have another two variables in a adition to a point. I tried using a class which had all neccissary variables and then tried to use it in a simar type collection but this didnt work.
How should I go about this??? CObArray??
I need to be able to 'add'Items and then read items sequentially.
thanks for the time
|
|
|
|
|
You can create separate instances of the class using new.
Then add the pointer to that class data to the CObArray.
Just remember to create a function to properly delete items prior to emptying the array, or else you will discover that you have memory leaks.
I usually use a for loop to fetch each item's pointer, delete the items via the pointer, then erase all the pointers by calling RemoveAll on the array when I am done with the data.
|
|
|
|
|
See: http://home.socal.rr.com/samhobbs/VC/Collections.html
The CObList sample can probably be used as an exmple of a CObArray also, with the obvious variations.
I think, however, that a CArray would be good too and might be easier. If you used it as in:
CArray <cfieldsrecord, cfieldsrecord&=""> m_FieldsRecords;
then it would store and retrieve your class items and you could delete everything with a simple:
m_FieldsRecords.RemoveAll();
when you are through. So what was the problem with CArray? I have used them and they work well and are easy to use. I think it would be worthwhile to determine what the problem is and solve it.
|
|
|
|
|
Well In fact I did solve the problem with the CArray and again Im sorry for the poorly written post I was a little
mindboggled last night!!!
I have a class whose constructor is as follows
JPoint(CPoint CP, int state, int Ptool);
This is the object I needed an array of..
In a SetCoordinates function I had code similar to this:
FixedMap.Add(JPoint((100,100),0,1));
Still a newbee I assumed that (100,100) would be assumed to be the CPoint required by the JPoint constructor;
And the fact I recieved no compiler errors lead me to beleive it should work. But when it came draw the points in another function nothing was displayed...
The problem was not prefixing (100,100) with CPoint as follows
FixedMap.Add(JPoint(CPoint(100,100),0,1));
Shouldve known better right???
|
|
|
|
|
Can anyone tell me how to start a thread from inside a class's member function? I keep getting this error
C2664: '_beginthread' : cannot convert parameter 1 from 'void (void *)' to 'void (__cdecl *)(void *)'
None of the functions with this name in scope match the target type
Is this because I'm compiling it as a DLL? The _beginthread call looks like this:
_beginthread(WindowThread, 0, NULL);
and WindowThread is defined as:
friend void WindowThread(PVOID pvoid);
What am I doing wrong? I declared WindowThread as a friend inside the class definition, and I also tried it as a global function outside of the class. I'm stuck.
Thanks for any help given,
- J Woltman
|
|
|
|
|
You should use _beginthreadex instead.
In class you define these:
// used for _beginthreadex
static DWORD WINAPI WriterStartThread(LPVOID);
// thread function which handles messages
virtual DWORD WriterThread(void);
// set when the thread has started running
HANDLE m_WriterThreadEvent; // write thread start event
// handle to the play thread
HANDLE m_WriterThreadHandle; // write thread handle
// thread identifier of play thread
DWORD m_WriterThreadID; // write thread identifier
This is in class function that starts the thread...
// start thread
m_WriterThreadHandle = (HANDLE)_beginthreadex(
(void *)((LPSECURITY_ATTRIBUTES)m_SecurityInfo),
0, // normal stack size
(PFBTEX)WriterStartThread,
(LPVOID)this, // pointer to this class
0, // instance data not used with callback threads
(unsigned *)&m_WriterThreadID
);
This is static member function that just acts to hand off call to the class virtual function.
It maps from the static domain into the class domain so that all thread processing can actually get to member variables.
// static
DWORD WINAPI MWCWaveFileWriter::WriterStartThread(
LPVOID lpData
){
// run member function
DWORD dwRetVal = ((PMWCWaveFileWriter)lpData)->WriterThread();
return( dwRetVal );
}
|
|
|
|
|
When I looked up the documentation, I found that my error was with the using of __stdcall instead of __cdecl function calls. Is there I way I can explicitly tell it to use __cdecl for just the thread function? (I know that is probably a basic question, but I don't know how)
Thanks for the reply,
- J Woltman
|
|
|
|
|
Okay, nevermind, I kept reading (RTFM, I know I know and I got it to work by adding __cdecl to the function declaration.
- j woltman
|
|
|
|
|
Declare as follows
<return type=""> __cdecl <function name="">(Function Arguments>);
For example...
BOOL __cdecl MyFunction(int, int);
|
|
|
|
|
Great... My last exmaple got MUTILATED by HTML parsers...
Okay, let's try again...
Declare as follows
{ReturnType} __cdecl {FunctionName}({Function Arguments});
For example...
BOOL __cdecl MyFunction(int, int);
And for the function that would be passed to the _beginthredex call, if it were a member function of a class, just add 'static' in front of all that...
static BOOL __cdecl MyFunction(int, int);
That prevents the compiler from adding the hidden 'this' parameter as the first argument.
|
|
|
|
|
I created a custom control derived from CWnd. I need to cascade many of these on a CFormView. I am able to create and cascade them but when I click on a portion of the top most control which is over another control, the control underneath receives the mouse input and not the top most one. I tried to disable the previous control but I need to receive WM_ messages for all the cascaded controls.
I also tried this with a standard CButton class and the same problem occured.
Does anyone know how to prevent this behaviour?
Thanks in advance
|
|
|
|
|
We do seem to have amazingly similar problems in spite of the applications being quite different. My application is for subitem editing of a list control, which also uses overlapped windows.
So thank you for mentioning SetWindowPos. There are so many functions like it and the documentation does not make it clear that SetWindowPos would be useful in my situation.
I think that something else I would have tried instead is BeginDeferWindowPos, EndDeferWindowPos and DeferWindowPos. I do not understand exactly what they do and how they work but they might be useful when the z-order of multiple windows needs to be specified. Are they not relevant to you situation?
|
|
|
|
|
Anyone know how to reset the z-order of a window's children to be a specified z-order? Actually, I only need to be able to specify which child to be on top. I am hoping to control which child window gets the mouse click this way. So far setting focus does not work to determine who gtets the mouse click. SetActiveWindow does not affect the z-order, and I think that there is nothing to counter-act it but I will attempt to ensure that that is not a problem.
|
|
|
|
|
To set the Z-Order:
SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE)
|
|
|
|
|
Thank you. I think it is working. Since I am using MFC, I converted your sample to:
m_pEditWindow->SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
There are still some problems with my program but it is likely that they are separate problems. I think that the z-order part is probably solved.
|
|
|
|
|
Hi all,
i have a problem with a function which writes a DIB to a BMP file. The strange thing is that it works with small pictures but fails with big ones
(it messes up the dimensions...)
The raw bitmap data is saved in a 32 bit format, so i have to convert it to 24 bit first. Here is the code...
BITMAPFILEHEADER bfh;
BITMAPINFOHEADER bih;
unsigned char *data=(unsigned char*)malloc(3*m_nDataBr*m_nDataHo); // for the 24 bit data
unsigned char *p=(unsigned char*)m_pdwData; // this is the 32 bit data
for (int i=0, j=0; i<4*m_nDataBr*m_nDataHo; i++) {
data[j++]=p[i++];
data[j++]=p[i++];
data[j++]=p[i++];
}
// Initialize all structures
memset(&bfh, 0, sizeof(BITMAPFILEHEADER));
memset(&bih, 0, sizeof(BITMAPINFOHEADER));
bih.biSize=sizeof(bih);
bih.biBitCount=24;
bih.biHeight=m_nDataHo;
bih.biWidth=m_nDataBr;
bih.biPlanes=1;
bih.biCompression=BI_RGB;
// Fill in the Bitmap File Header
bfh.bfType=((WORD)('M'<<8)|'B');
// Calculate the size of the bitmap including the palette (which should be empty)
bfh.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+m_nDataHo*m_nDataBr*3;
bfh.bfReserved1=bfh.bfReserved2=0;
// Offset to actual bits is after palette
bfh.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
ASSERT(bfh.bfSize>sizeof(BITMAPFILEHEADER));
// Write the results
fwrite(&bfh, sizeof(BITMAPFILEHEADER), 1, f);
fwrite(&bih, sizeof(BITMAPINFOHEADER), 1, f);
fwrite(data, m_nDataHo*m_nDataBr*3, 1, f);
I really don't know what i am doing wrong here... if anybody could help me i really would be glad.
Chris
|
|
|
|
|
Hi Chris,
What exactly is the problem?
Are you able to open the image in some editor?
|
|
|
|
|
Well, if the image is not very big (lets say 200x200 pixels) then it's no problem at all. If it's bigger you
still can open it in a editor, but with some strange effects:
- it might be stretched
- some parts of the image might be grey, not colored
things like that.
|
|
|
|
|
Now I remember that Windows bitmaps must be 32-bits aligned, that is the length of each row must be a multiple of 4 (padded with zeroes).
So you have to re-code the loop which converts the image from 32 to 24 bits to do the alignment.
I forgot that!
Cheers,
Paolo.
|
|
|
|
|
You may also take a look at WINCAP sample in Knowledge Base art. no. Q97193, which contains the DIB API.
|
|
|
|