|
kk_vp wrote:
How to Post a message??
Try PostMessage() .
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Is MyNotify ever being called? Have you set a breakpoint there? Please show the code in which you register the callback.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Hi,
Instead of giving solution, I have a lot of questions!! to ask you.
1. Possiblity 1: I think your MyNotify() call back function is not called or not set. Have you placed the MyNotify() function inside the your application cpp file.
2. Possiblity 2 : Otherwise, MFC maintains its state (some internal flags) which cannot be accessed by a normal dll. For example, if you want to use MFC inside a win32 dll, you cannot. It should be a MFC extended dll. So consider this possiblities also while to dig into the problem...
3. You have mentioned you are calling the MyNotify()from a dll. Did you export that function?. If it is How did you export a main exe file to a dll?.
If you register your MyNotify() function, you have to give the address of that function, but how did you get the MyFunction address..
One thing you can do is, call a dll function with the notification function address as a parameter, set that address when you register your callback function..
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
Why not intercept the EN_CHANGE message sent to an edit box and do something about that change.
or EN_UPDATE
gabby
|
|
|
|
|
MyNotify is ok. It is being called. But if I write MessageBox("Hello"); I get an error, MEssageBoxA does not take one parameter.
I guess this is because MyNotify is not member of CDialog.
I want to do a SetDlgItemText on a edit box in my Dialog.
So, how to access a edit box in a dialog from a function which is not a member of the dialog class ?
If it was a normal function, I could have passed a pointer of Dialog to the function and used it. But, this is a callback function. THe call back portion of it is working fine.
So other than passing a pointer to dialog, how to access a edit box in a dialog from a function which is not a member of the dialog class ?
- KK
|
|
|
|
|
kk_vp wrote:
I guess this is because MyNotify is not member of CDialog.
Yeap you are right, the MyNotify function is a global function, so It's calling global MessageBox(...) which take 4 parameter instead of CDialog::MessageBox....
kk_vp wrote:
I want to do a SetDlgItemText on a edit box in my Dialog.
You have to get pointer to the Dialog Box and put the value in the Edit Box!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
You have to get pointer to the Dialog Box and put the value in the Edit Box!
- YES. but how do I pass a pointer to a callback function. This callback was written by somebody else and I have not much idea. Any tutorial on CALLBACK functions that you know of??
- KK
|
|
|
|
|
Is IDC_EDITCustLog item child of your Main Window.. Is it dialog based application?. Where IDC_EDITCustLogis placed?
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
Yes. This is a dialog based application. IDC_EDITCustLog is an edit box placed inside the dialog.
- KK
|
|
|
|
|
Hi KK_VP (Whats this yar)??????!!!
One more catch up from my mind..
You told your callback function is called from a dll..
From the callback function you are tring to set the window text.
The problem could be, you might have different thread(Secondary thread..), from where your callback function could be called. To check this, display a message box or trace the currentthreadid() value in your InitInstance() and also in your notification function. If you get different values, you must do the PostThreadMessage to the thread where you have created your dialogs..
Hope the above approach will help you..
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
Hi,
its wonderful to get HTML out of MIME buffer. I am able to get HTML out of almost all of my MIME buffer but it is failing for some cases.
Here is the MIME buffer where it crashing when I try to use get body from it.I anaysed that it always crash if HTML body starts with <DIV> or <P> tag.
Content-Transfer-Encoding: binary
Content-Type: text/html; charset=ISO-8859-1
<div><STRONG><FONT color=#ff9900>RTF NOT NULL Without attachment Title-099</FONT></STRONG></div>
code:
// hTempFile it contains handle of My MIME buffer file
CFileSystemStream SourceStream(hTempFile);
IMimeDecoderPtr Decoder;
IPersistStreamPtr pPersist;
Decoder->QueryInterface(&pPersist);
pPersist->Load(&SourceStream);
IMimeBodyPtr Body;
Body = Decoder->Body; -----------------------------------> it crashes here even I tried to put try catch block it never catch.
Mentioned MIME buffer comes from Quick Place. Quick Place is able to convert these MIME buffer into HTML correctly.
Is there any validation check for MIME buffer for MIMEsniffer.dll? How to validate the MIME buffer. I tried to put <HTML> </HTML> and <BODY> </BODY> tag to my MIME buffer and passed it to MIMEsniffer.DLL even it gets crashed.
could you help me out ?
Thanks in advance.
Chandan Kumar
VIT infotech
|
|
|
|
|
chandan kumar wrote:
IMimeDecoderPtr Decoder;
Just like that? Shouldn't you be creating an object to instantiate that interface?
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Hi,
its wonderful to get HTML out of MIME buffer. I am able to get HTML out of almost all of my MIME buffer but it is failing for some cases.
Here is the MIME buffer where it crashing when I try to use get body from it.I anaysed that it always crash if HTML body starts with <DIV> or <P> tag.
Content-Transfer-Encoding: binary
Content-Type: text/html; charset=ISO-8859-1
<div><STRONG><FONT color=#ff9900>RTF NOT NULL Without attachment Title-099</FONT></STRONG></div>
code:
// hTempFile it contains handle of My MIME buffer file
CFileSystemStream SourceStream(hTempFile);
IMimeDecoderPtr Decoder;
IPersistStreamPtr pPersist;
Decoder->QueryInterface(&pPersist);
pPersist->Load(&SourceStream);
IMimeBodyPtr Body;
Body = Decoder->Body; -----------------------------------> it crashes here even I tried to put try catch block it never catch.
Mentioned MIME buffer comes from Quick Place. Quick Place is able to convert these MIME buffer into HTML correctly.
Is there any validation check for MIME buffer for MIMEsniffer.dll? How to validate the MIME buffer. I tried to put <HTML> </HTML> and <BODY> </BODY> tag to my MIME buffer and passed it to MIMEsniffer.DLL even it gets crashed.
could you help me out ?
Thanks in advance.
Chandan Kumar
VIT infotech
|
|
|
|
|
Hi!
How can I create a button on a Dialog that can be dragged and dropped?
Thanks!
|
|
|
|
|
|
Hi,
There is no direct method available for this..
You can follow the following steps.
Assumption: Parent window and children to be draged already created
You need to handle three mouse events.. WM_LBUTTONDOWN, WM_MOUSEMOVE, WM_LBUTTONUP
1. In the WM_LBUTTONDOWN message, call the SetCapture function with the control ID
2. In the WM_MOUSEMOVE message, call the GetCapture method and check the returned Window handle againt the your window child control window handle. If both are same, call SetWindowPos() to set the control new position.
3. In the WM_LBUTTONUP, check for the GetCapture() returned window handle is equal to your window control handle. If it is call ReleaseCapture() method, and once again place the window control by using SetWindowPos().
One more thing you have to take care is , when user clicks the button, he can drag that button out of parent window. To avoid such a situation, call the ClipCursor() function with the parent window rectangle size values...Then don't forgot to free the cursor. That you can do it by ClipCursor(NULL)..
Enjoy programming...
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
Thanks!
But can this be done using OLE drag and drop?
If so, how do I do it?
Can't seem to find any good information of how to drag Controls.
Thanks!
|
|
|
|
|
No. You cannot..
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
Hi Guys,
I hope someone here knows more about managed c++ than i do.
The problem: I get a char* from a structure, and i need to convert it to a String*(or a Stringbuilder). The way i do it is hopelessly inefficient. Is there any way to improve on this.
<br />
Mail *mail = new Mail();<br />
<br />
for (int a=0;a < 1000;a++)<br />
{<br />
mail->String = new String(struct[a].subject,0,struct[a].subjectSize); <br />
}<br />
What i'd like to do is some thing like this. But i dont know how.
<br />
Mail *mail = new Mail();<br />
mail->String = new String( <br />
for (int a=0;a < 1000;a++)<br />
{<br />
mail->String =
}<br />
Thanks
|
|
|
|
|
Hello,
I don't know what you are trying to do here, but you initialize the mail object a 1000 times and in the end it will only hold the last element.
Let me get the case clear here: you have an array of 1000 structures and one mail object. You want 1000 email objects initialzed with each of the structures. Right?
So please describe your problem a little better, because now it doesn't make much sense to me.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hi Bob,
Thanks for the reply. I'm creating only one instance of the Mail object. In each iteration I instantiate a new String from the char*
I got from mailStruct[a].subject, and I raise an event (The mail object is processed on the other side).
<br />
Mail *mail = new Mail();<br />
<br />
for (int a=0;a < 1000;a++)<br />
{<br />
mail->String = new String(mailStruct[a].subject,0,strlen(mailStruct[a].subject)); <br />
MailEvent(mail);<br />
}<br />
A new String* instance is created with each iteration. This translates into a new memory allocation on each iteration and more work for the garbage collector.
So i'd like to change the code so that i create only one new String.
<br />
Mail *mail = new Mail();<br />
mail->String = new String (
for (int a=0;a < 1000;a++)<br />
{<br />
mail->String =
MailEvent(mail);<br />
}<br />
|
|
|
|
|
ok, I think I get it, you more or less want to send a 1000 email with different strings ?
I think your on the right track with your second example.
is the Main object you own ? does it allocate the String object when it gets constructed ?
I would change the definition of the String member to not be dynamically allocated; if not, you will need to allocate it like you do before the loop.
if the String is a build-in type of the managed c++ language, just assign it a new string in the loop should remove the old one and put the new one in;
Be certain that if you allocate it with new, that youp delete it ( or not, it might be collected later ).
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
You're spot on. Thats exactly what i'm doing.
I defined the Mail as a managed struct and it contains a bunch of managed c++ Strings.
The Mail struct doesn't allocate the String when it's constructed. (This is exactly what it looks like)
typedef __gc struct Mail
{
String *entryid;
String *tempid;
String *storeid;
String *subject;
String *fromName;
String *fromEmail;
}
The String is "newed" with every iteration. You're right, the garbage collector should take care of this. But why put the garbage collector under strain, when it may be unnecessary.
How can i allocate the memory for the String only once? But change its value a 1000 times?
|
|
|
|
|
Since string is a class, it must have member functions. So, you should be able to use those to alter it's contents. The most logical thing would be that operator = is implemented to replace the contents with something else.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hello guys,
i'm stuck with this problem, i wrote a class wich handles the resizing en reposition of controls when a dialog resizes, but the problem is when I resize the dialog from the top or from the bottom you see a ghost of the control. This gives the effect that the controls are shaking during a resize.
The problem I think is, is that when MFC resize the dialog it updates the dialog and it's controls so you will see the controls with their previous x & y coordinates, then mfc calls my overriden onsize where i update the controls coordinates and size and repaint the dialog. So my question is how can i stop mfc from repainting the dialog when is resized so i can do this manual after mine onsize.
I checked other implementations of the CResizableDlg classes articles here, but they seem to have the same problem.
Anyone got some suggestions
Thanks Remco
|
|
|
|