|
prithaa wrote: What exactly is dlg subclass ?.
In general, a subclass is this.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
To understand window subclassing and how the MFC framework subclasses windows, you should have a
good understanding of the fundamentals of Windows programming: Windowing[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
What is the relationship between subclassed dialog item and
DLGTEMPLATE d;
d.cdit
One of the demo code given for "Dynamic creation of Dialogs" saya
if a dialogitem is subclassed only then it can be added to to d.cdit.
This part of subclassed dialog item is what I did not understand.
Thanks for all your replies and cooperation.
Prithaa
|
|
|
|
|
prithaa wrote: What is the relationship between subclassed dialog item and
DLGTEMPLATE d;
d.cdit
None that I know of. The template is used for dialog creation.
Once a dialog and its items (controls) have been created then you can subclass them.
prithaa wrote: One of the demo code given for "Dynamic creation of Dialogs" saya
if a dialogitem is subclassed only then it can be added to to d.cdit.
That doesn't make sense. Do you have a link to that? Is it the MFC DLGTEMPL Sample?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Hello ,
Thanks,for all your support.
I have understood almost everyting about the dialogs with your help.
One last question about subclass.
You said that
Once a dialog and its items (controls) have been created then you can subclass them.
What does the above statement mean?
I was referring to Dynamic Dialog Class by Marcel
Thanks
Prithaa
|
|
|
|
|
prithaa wrote: You said that
Once a dialog and its items (controls) have been created then you can subclass them.
In order to subclass a window (or control) it needs to have an HWND. That means the window has to
exist (be created) before you can subclass it.
Reminder/Note: In MFC, windows are created in two steps -
1) A C++ object (CWnd) is created
2) A window object (HWND) is created
To attach an MFC C++ object (CWnd) to a control in a dynamically created dialog (which already
has a valid HWND), you need to force the subclass to occur (usually this is done by the MFC DDE
mechanism), which is what you use CWnd::SubclassDlgItem() for. Once MFC has the control
subclassed, it can pass messages through the message map mechanism as usual.
You don't HAVE to subclass the controls of the dynamically created dialog. You only need to do
it if you need to associate them with an MFC object or provide special message handling beyond
what the control already does.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
I wrote a code (written as a SDI) that connects to DB (via ODBC) and does some work and views the results on a form.
But I need to add this to a bigger MDI project. How can I add it?
I thought of two ways :
1- directly add the DB project to the main project(which I don't know how)
2-create .lib out of the database project abd include it. But I don't know how make a .lib that contains CRecordset and Form View ...
Any idea?
Thanks a lot....
|
|
|
|
|
in my program, i need to hold infinite value in a string.
it is very easy for normal value, ie.
char*psz="33.33" is a string which holds value 33.33, because we can use atof() function to get the value 33.33 from "33.33".
but, how to hold infinite value in a string?
following is my test:
//----------------------------
CString cs;
double db1=1/sin(0);
cs.Format("%f",db1);
double db2=atof(cs);
//-------------------------
cs is displayed as "1.#INF00"
value of db2 is 1.00
we can explain why atof("1.#INF00") is 1.00 for code above.
but how to hold the infinite value db1 in a string "..." so that its value can be re-generated by atof("...") function?
|
|
|
|
|
Why not use cs.GetBuffer(),ReleaseBuffer() ? and then use atof()?
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
|
GetBuffer retrieves a pointer to buffer and when use of GetBuffer you must use of ReleaseBuffer and atof for convert of string to double.
Does this your answer?
|
|
|
|
|
you are making fun to yourself.
next time, read post first before writing down your funny reply.
|
|
|
|
|
I remember that most your replys got low vote like here[^] do you know why?
|
|
|
|
|
includeh10 wrote: but how to hold the infinite value db1 in a string...
Use gcvt() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Why the following piece of code that simply reads the current pos & size of the CEdit control makes the control to change its size regardless that no changes of top,left,bottom,right values are made ?
pEditSearch = (CEdit*) pPage->GetDlgItem(IDC_EDITSEARCH);
pEditSearch->GetClientRect (&rectChild);
pEditSearch->SetWindowPos (NULL,rectChild.top, rectChild.left, rectChild.right, rectChild.bottom ,SWP_NOMOVE | SWP_NOZORDER | SWP_SHOWWINDOW);
This piece of code is used in a left pane view (using a CSplitterWnd class) and my goal is to change the right border of the CEdit control accordingly of the pane size (just like a .CHM help file with am index).
Regards,
sdancer75
|
|
|
|
|
sdancer75 wrote: ...regardless that no changes of top,left,bottom,right values are made ?
The "change" comes in the form of client vs. screen coordinates.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Maybe try this (changes in red):
pEditSearch = (CEdit*) pPage->GetDlgItem(IDC_EDITSEARCH);
pEditSearch->GetWindow Rect (&rectChild);
ScreenToClient(&rectChild);
pEditSearch->SetWindowPos (NULL,rectChild.left, rectChild.top, rectChild.Width(), rectChild.Height() ,SWP_NOMOVE | SWP_NOZORDER | SWP_SHOWWINDOW);
Note SetWindowPos takes x,y,cx,cy - not y1,x1,x2,y2, like you were passing!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Ok I traced the error with your help Mark.
1. Totaly wrong parameters to SetWindowPost
2. It worked only with the GetWindowRect & ScreenToClient and not with GetClientRect ( I am curious why not???).
The combination of GetWindowRect / ScreenToClient should give the GetClientRect position, Am I wrong ?
Regards,
sdancer75
|
|
|
|
|
Did you use of ScreenToClient on your code it converts screen coordinates to client coordinates.
|
|
|
|
|
Hi everyone,
Can anyone tell me, how to check whether entered text is RTL (for example: Arabic or Hebrew) or LTR(for example:English) text?
I am using Uniscribe in my application. If i don't use ETO_RTLREADING in ExtTextOut(), can i get correct output based on English or Arabic language entered?
Thank you,
|
|
|
|
|
|
hi everyone,
i'm working on a project which includes a DLL and a separate UserBroker (both written in ATL) object which is used for getting/setting registry keys and reading/writing to user directories. (the object will be used in Vista, so this is needed)
i want to read some binary data from registry and i have written this function properly:
STDMETHODIMP CUserBroker::QueryBinaryValue(BSTR bstrKeyName, BSTR bstrValueName, BYTE **pValue, ULONG *pnBytes)
the function body is simple. it just opens the registry key (using a CRegKey ) and uses its QueryBinaryValue method. the problem is somehow i just can't pass a BYTE array to the other process (which calls the CUserBroker 's method). the call to the method is this:
arr = (BYTE *)malloc(1 * sizeof(BYTE));
pub->QueryBinaryValue(ATL::CComBSTR(s_bstrToolBarRegistryKey), ATL::CComBSTR("hop"), &arr, &dwSize);
arr = (BYTE *)realloc(&arr[0], (dwSize) * sizeof(BYTE));
pub->QueryBinaryValue(ATL::CComBSTR(s_bstrToolBarRegistryKey), ATL::CComBSTR("hop"), &arr, &dwSize);
delete arr;
everything works fine until the first line of CUserBroker::QueryBinaryValue method, where the BYTE** pointer points to BadPtr (0x00000000) immediately.
the question: how can i pass a BYTE array (or any other array) among processes?
|
|
|
|
|
|
|
thanks, the article was really helpful. i used BSTR to pass the array safely among processes. i thought i needed some structure like BSTR for this, but couldn't imagine the solution would be BSTR itself
WM_COPYDATA is useful too, but since my UserBroker does not have a window, i can't send the message to anywhere else.
thanks again
|
|
|
|