|
Hey! I'm trying to get a child dialog to show up in a pure Win32 app.
What I want to do is use the dialog as half of the UI and use a simple ListBox (created with CreateWindowEx) as the other half.
Here's what I'm trying:
hCtrls = CreateDialog( hInst, (LPCTSTR)IDD_GAMEINFO, hWnd, (DLGPROC)DlgGameInfo );
The line of code works for all non-child dialogs (like my About and Options dialogs), however as soon as I specify in the resource editor that my IDD_GAMEINFO should be a child it doesn't work.
Any help is appreciated! Thanks
./[tiller]
|
|
|
|
|
|
The hWnd is the HWND variable that the main window's WndProc message handler recieves.
In the switch statement for the various windows messages I basically have the following to create my UI:
case WM_CREATE:
HWND hCtrls;
// Listbox works
hCtrls = CreateWindowEx( WS_EX_CLIENTEDGE, "LISTBOX", "",
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL,
5, 5, 200, 340, hWnd, (HMENU)IDC_GAMELISTBOX,
GetModuleHandle(NULL), NULL);
// Static frame works
hCtrls = CreateWindowEx( WS_EX_CLIENTEDGE, "STATIC", "",
WS_CHILD | ~WS_VISIBLE | SS_GRAYFRAME,
210, 5, 250, 340, hWnd, (HMENU)IDC_GAMEINFOFRAME,
GetModuleHandle(NULL), NULL);
// CreateDialog returns a NULL (IDD_GAMEINFO is my dialog resource)
hCtrls = CreateDialog( hInst, (LPCTSTR)IDD_GAMEINFO, hWnd,
(DLGPROC)DlgGameInfo );
// I also added this later to try it...but it didn't help:
ShowWindow( hCtrls, SW_SHOWNORMAL );
UpdateWindow( hCtrls );
I experimented a bit...the code with no modification works if I specify in the resource editor that the dialog is a regular popup with a border, etc. But of course then it's a popup...and I want it a part of the actually window. (Like a common control would be)
Thanks,
./[tiller]
|
|
|
|
|
Not sure that this is your case, but for child dialogs you have to ensure that the WS_VISIBLE style attribute is set in the resource.
|
|
|
|
|
Yeah...I have WS_VISIBLE selected.
./[tiller]
|
|
|
|
|
I have a member variable of a class declared as a pointer to type double, m_dHessianMatrix . This variable will be holding a 2 x 2 matrix (could be larger)and needs to be initialized completely to zeroes to start. As such, I need something to init the matrix to zero quickly (thus a for loop will not do particularly for LARGE matrices).
Currently I am initializing the matrix data in the constructor as follows:
CROT_Optimizer::CROT_Optimizer(UINT MaxNodes)
{
ASSERT (MaxNodes > 0);
if (MaxNodes == 0)
return;
m_uiNumberOfNodes = MaxNodes;
m_uiNumberOfSprings = 0;
m_ppNodeIndexedSpringArray = NULL;
m_dHessianMatrix = NULL;
m_dHessianMatrix = new double[4];
memset(m_dHessianMatrix, 0, sizeof(double));
}
However, I don't like this for two reasons.
1.) I have to include string.h to gain access to the memset function ->code bloat
2.) It is not aesthetically pleasing to the eye
Is there a way to initialize the matrix without using a for loop and without using memset() ?
|
|
|
|
|
|
Ah, ok. One question.
If I have a 4 element matrix, is the proper syntax:
ZeroMemory(&m_dHessianMatrix, sizeof(double));
<pre><code>
ZeroMemory(&m_dHessianMatrix, 4*sizeof(double));
?
(Thanks for the suggestion)
|
|
|
|
|
ZeroMemory(&m_dHessianMatrix, 4*sizeof(double));
John
|
|
|
|
|
What functions/classes should I use for thread syncronization inside a module that is used in both ATL and MFC projects?
-Alma-
|
|
|
|
|
Use the win32 API. CreateEvent(), CreateMutex() ...
John
|
|
|
|
|
Yeah, right!
Thanks!
-Alma-
|
|
|
|
|
Hi all,
How can i create an abstract class without using virtual keyword in c++.
Mahesh
|
|
|
|
|
You can't.
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
"You won't like me when I'm angry..." - Dr. Bruce Banner
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|
|
??? If you use inherance overloading without virtual you will run into trouble.
If you want to avoid virtual methods, use template meta programming.
Jonathan de Halleux.
|
|
|
|
|
Is there a particular reason you don't want to use virtual ?
- Mike
|
|
|
|
|
I was thinking the same.
John
|
|
|
|
|
Hi Mike,
Thanks.. No particular reason mike. It was an interview question.
I just want to confirm whether it is possible.
Mahesh
|
|
|
|
|
You can't - an abstract class is defined as having at least one method be virtual and not having an implementation. e.g.,
class VirtualClass
{
public:
virtual void OverrideMe() = 0;
};
A compiler won't let you instantiate such a class. If you can instantiate it, then it is not an abstract class.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
We can prevent the instantiation of the class by making it's constructors private, however the problem with this is that the class cannot be derived then.
|
|
|
|
|
Just a thought... did you have the __declspec(novtable) extension in mind?
If so, keep in mind that the novtable attribute does not semantically mark the class as abstract; rather, it just removes the vtable initialization code. It just happens that this is most useful for application to abstract classes.
- Mike
|
|
|
|
|
Hi,
Im writing 2 programs in VC++6 that broadcast messages to each other. One is a full blown windows program, complete with message map and handles incoming messages perfectly. The second however is a small console program, consisting of int main() and 1 global function. All of the examples i have seen implement the message map in dialog classes. Is it possible to implement it globally like shown below?
MESSAGE_MAP()
....
void GotAMessageWooYay()
{
...
}
int main()
{
...
}
|
|
|
|
|
How are you going to broadcast messages to the console application?? I think you need at least a hidden window there. Unless you send thread messages.
John
|
|
|
|
|
I agree, messages are sent through the winproc, and if there is no window, there is no proc.
|
|
|
|
|
Does anyone know how to get around the 31 character limit in IStorage::CreateStorage and IStorage::CreateStream?
I am trying to use the IMAPI functions to programmatically burn data to a cd which I have been able to do successfully, however, I can't seem to get around the 31 character limit when trying to burn a file whose name exceeds 31 characters.
Any suggestions?
|
|
|
|