Jump to content
  • Advertisement
Sign in to follow this  
Claudio

dialog Box

This topic is 3173 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. I use DirectX 9. I want to create a displaied box where there are more than one choice for the user. An example is: the user has to select one button on five buttons in the displayed box. Someone can help me ?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Erik Rufelt
win32 dialog box tutorial


Hi.

But how can I integrate the dialog box into my code ?

The main window procedure code is:

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpStr, int iShowMode)
{
WNDCLASSEX wceWndClassEx; // creation of the extended window structure class
ZeroMemory(&wceWndClassEx, sizeof(wceWndClassEx)); // initializzation (memory block to 0)

// insert of the parameter in the structure WNDCLASSEX:
wceWndClassEx.cbSize = sizeof(wceWndClassEx);
wceWndClassEx.style = CS_HREDRAW | CS_VREDRAW;
wceWndClassEx.lpfnWndProc = (WNDPROC)MainWindowProc;
wceWndClassEx.cbClsExtra = 0;
wceWndClassEx.cbWndExtra = 0;
wceWndClassEx.hInstance = hInstance;
wceWndClassEx.hIcon = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 0, 0, LR_SHARED);
wceWndClassEx.hCursor = NULL;
wceWndClassEx.hbrBackground = NULL;
wceWndClassEx.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);
wceWndClassEx.lpszClassName = __TEXT("Name");
wceWndClassEx.hIconSm = NULL;

// registration of the WNDCLASSEX
if (RegisterClassEx(&wceWndClassEx) == 0)
{
MessageBox(NULL, __TEXT("Registration of the class is not correctly executed!!!"), __TEXT("Error"), MB_ICONERROR);
return 0;
}

// width and height of the client area of the application window:
LONG lHeightClientArea = GetSystemMetrics(SM_CYSCREEN); // height of the desired client area
LONG lWidthClientArea = GetSystemMetrics(SM_CXSCREEN); // width of the desired client area

// definition of the corners of the application window:
RECT lprSizeClientWindow;
lprSizeClientWindow.left = 0;
lprSizeClientWindow.top = 0;
lprSizeClientWindow.right = lprSizeClientWindow.left + lWidthClientArea;
lprSizeClientWindow.bottom = lprSizeClientWindow.top + lHeightClientArea;

DWORD dwExStyle = WS_EX_OVERLAPPEDWINDOW;
DWORD dwStyle = WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME; // no re-size of the dimension of the window

// creation of the application window:
HWND hWindow = CreateWindowEx(dwExStyle, __TEXT("FX App Window Class"),
__TEXT("Window Name"), dwStyle, lprSizeClientWindow.left, lprSizeClientWindow.top, // Position of the window: horizzontal and vertical position
lprSizeClientWindow.right-lprSizeClientWindow.left, lprSizeClientWindow.bottom-lprSizeClientWindow.top, // width and height of the window
NULL, NULL, NULL, NULL);

if (hWindow == NULL)
{
MessageBox(NULL, __TEXT("Failed Creation of hWindow !"), __TEXT("Error"), MB_ICONERROR);
return 0;
}

InitGraphics(hWindow);

ShowWindow(hWindow, SW_SHOWNORMAL);

// Message Pump
for (MSG msg;;)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
{
ReleaseGraphics();
return (int)msg.wParam;
}

TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
// rendering
Render();
}

}



And the callback of the window procedure is:


LRESULT CALLBACK MainWindowProc(HWND hWindow, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
....
switch(uMessage)
{
case WM_CLOSE:
DestroyWindow(hWindow);
return 0;

case WM_DESTROY:
PostQuitMessage(1);
return 0;

case WM_SIZE:
return 0;

// menu messages queue
case WM_COMMAND:
switch(wParam)
{
...
}

// mouse left button messages queue
case WM_LBUTTONDOWN:
return 0;

case WM_MOUSEMOVE:

return 0;


// keyboard messages queue
case WM_KEYDOWN:
return 0;
default:
return DefWindowProc(hWindow, uMessage, wParam, lParam);
}
}


Share this post


Link to post
Share on other sites
If you're not very familiar with Windows programming using the Win32 API, you probably should try a few non-DirectX Windows projects first to get an understanding of windows messaging. You're going to need to understand menus, messages, window procedures, etc., to successfully get input for your DirectX applications.

Having said that: When you ask for help, you might want to actually look at what Erik posted. For instance.

Share this post


Link to post
Share on other sites
Quote:
Original post by Buckeye
If you're not very familiar with Windows programming using the Win32 API, you probably should try a few non-DirectX Windows projects first to get an understanding of windows messaging. You're going to need to understand menus, messages, window procedures, etc., to successfully get input for your DirectX applications.

Having said that: When you ask for help, you might want to actually look at what Erik posted. For instance.


Hi.

The single thing is ok but the match between them is not more clear.

Share this post


Link to post
Share on other sites
The link that I posted demonstrates how to incorporate a dialog box into a windows program (as do many of the links that Erik posted).

What problems did you have when you tried it?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!