|
I want to share some dialog resources to several apps.
I share my dialogs from a MFC extension DLL.
I keep getting the same problem with modeless dialogs.
When calling the CDialog::Create(), a blank dialog is shown. I have no problem accessing its child windows.
But there are simply not visible.
Displaying a Modal dialog works fine, the dialog is showed correctly...
Any ideas ?
|
|
|
|
|
I think MFC Tecnhical Note 11 addresses your problem. Quote follows:
Note that the CWinApp::Run mechanism doesn't apply to a DLL, since the application owns the main message pump. If your DLL brings up modeless dialogs or has a main frame window of its own, your application's main message pump must call a DLL-exported routine that calls CWinApp::PreTranslateMessage
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I am trying to write my own dialog class, but I'm having some problems conserning the dialogproc.
When my class creates a dialog with DialogBox() all messages are handles by the dialogproc. However I want the dialogproc to call an On... method of the dialog class for every message. For this the dialogproc has to have a reference to the instance of the class. My question is how do I pass the class reference to the dialogproc?
I could create a global or static member variable to hold the reference, but this is a problem when there are multiple instances of the dialog; the member variable will be overwritten.
Does anyone know a sollution for this problem?
regards,
Brian
sample code:
CAboutDialog* thisDialog = NULL;
int _stdcall DialogProc(HWND hwndDlg, //!< handle to dialog box
UINT uMsg, //!< message
WPARAM wParam, //!< first message parameter
LPARAM lParam //!< second message parameter
)
{
BOOL handled = FALSE;
if (thisDialog != NULL)
{
switch(uMsg)
{
case WM_INITDIALOG:
thisDialog->OnInitDialog(hwndDlg, wParam, lParam, handled);
break;
case WM_PAINT:
thisDialog->OnPaint(hwndDlg, wParam, lParam, handled);
break;
case WM_COMMAND:
thisDialog->OnCommand(hwndDlg, wParam, lParam, handled);
break;
}
}
return handled;
}
|
|
|
|
|
Try makin DialogProc a member function of your class. Or is that not allowed cause of the way it's prototyped?
If so create a PreDialogProc static member function with an extra 5th param that takes a class pointer. Now use this class pointer to call the class member dialog proc passin the first 4 params.
Nish
CPUA # 0x0666
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
Thanks for your reply but I already found the answer. Instead of using DialogBox to create the dialog I should use DialogBoxParam. This allows you to pass the this pointer of the class in the lparam of the WM_INITDIALOG message. Problem solved.
|
|
|
|
|
Store a pointer to your dialog class in the window data field of the actual dialog window.
Use the SetWindowLong function and set the GWL_USERDATA field.
Then in your static member function of the dialog class that you are using as your dialog proc function, call:
<br />
CYourDialog *pDlg = dynamic_cast<CYourDialog*>(GetWindowLong(hWnd, GWL_USERDATA));<br />
if (!pDlg)<br />
{<br />
}<br />
<br />
<br />
This trick will also work for regular windows. If you already have data stored in the USERDATA field, then you can simply convert this data to a structure and include the pointer to your object, or move the data into your class and still hold the this pointer in the USERDATA field.
|
|
|
|
|
I'm trying to add a drop down menu to a button using Windows SDK not MFC.
Thanks
|
|
|
|
|
I guess <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/CommCtls/winui/menus_0hdi.asp">TrackPopupMenu</a> is the place to start from.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
You need to create and track a popup menu in response to the button click. See CreatePopupMenu() and TrackPopupMenu.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi,
I'm migrating from GDI to GDI+ under Visual C++ 6.0.
I was calling SetPixelV on a device context. Now with a HDC and a graphics object, how to do a SetPixel ?
Thanks for your help
Nicolas
|
|
|
|
|
I don't know the answer,but Christian Graus has some articles about GDI+,put message there ,maybe he knows it.Check this
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Check out the SetPixel method the System.Drawing.Bitmap class?
|
|
|
|
|
I know this method exists but how to get a Bitmap reference of an existing DC with already drawn things in it ?
|
|
|
|
|
In an EXE I have a Dialog and I have another Dialog
which is started with DoModal()
in another thread using AfxBeginThread.
I want to hide this second Dialog
I have already tried to
ShowWindow( SW_HIDE );
MoveWindow( 0 , 0 , 0 , 0 , false );
But I still see the window on the taskbar.
Can anyone offer any solution.
Thanks,
Sansky
|
|
|
|
|
Cannot test this now, but I think that having the first dialog as the parent of the second one will prevent the latter from appearing on the taskbar.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi There,
I've gota project where I'll be using some dialog bars. I need to implement a tree control on the left side of the main frame that navigates between different screens, kind of like visual studio. I've embedded a CDialogBar member in the CMainFrame class, called create on it. I've got a dialog template where I'll stick a tree control, I guess.
At any rate, I imagine I'm not the first person to try this. Any tips? Any sample code you could recommend?
Thanks,
Aaron
|
|
|
|
|
|
Is it possible to use the Win32 API to setup user groups on Windows NT/2000/XP? If it is could someone please point me at the appropriate API calls.
Thanks for any help you can provide.
Systems AXIS Ltd - Software for Business ...
|
|
|
|
|
|
I have a small problem rendering lines in DirectX (Version 8) with DrawPrimitive, except, that there seems to be no way to set the width of the line. The same applies to points.
Does anybody know a solution!?
Thanks in advance.
Klaus
|
|
|
|
|
Hi,
I've got a CAsyncSocket derived class, trying to implement my own high level protocol.
My command structure consists of a variable length line of text. The kind of thing that a CStdioFile::Readline() likes.
I have an OnReceive() handler which successfully reads the data. To break it into lines, i'm appending my data to a buffer as i receive it, then searching the buffer for \r\n. then, chopping out the left most part of the buffer based on the offset i found the \r\n.
It's all a bit slow though. I'm pretty sure that wanting data line by line is a pretty common need when using CAsyncSocket. How do other people implement this, efficiently?
Jon
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Your method is essentially the only way to go. Winsock has no built-in support for breaking input into lines. So, if your app is lacking for speed, your only solution is trying to implement this search and cut algorithm more efficiently.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Just wondering if you have the option of just sending one line at a time.
Some command protocols are blessed with this type of exchange because there's nothing to do till the 1st one line finishes and data is returned to the client, others might use an app level ACK/NACK scheme - either way, each command is atomic.
|
|
|
|
|
Just wondering if you have the option of just sending one line at a time.
In general, no you can't. For connection-oriented sockets (TCP/IP), there's no guarantee at all as to how data chunks are to be received on the other end of the connection. In some cases, data chunks will be coalesced, in others they will be chopped. As a general rule, it is very bad design to assume that "boundary integrity" is preserved in any manner. Having this integrity for a particular network does not mean it'll be kept on another configuration (e.g. with different subnetworks) or even when the conditions on the network change (e.g. high traffic).
For connectionless sockets, aka datagrams (UDP), chunk integrity is preserved. But one has to be careful to not assume some fixed maximum datagram size (it can vary for different stacks and scenarios).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yes, fine, but if the client sends a line and waits for ack from the server before sending another...
|
|
|
|