Jump to content
  • Advertisement
Sign in to follow this  
The C modest god

Pop up window

This topic is 5052 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

Advertisement
if you didnt want the user to beable to copy the text you would just use the standard MessageBox function. however in your case it seems that youll need to write your own special window for this.

use CreateWindow to create the parent window which will be the size and shape of the standard messagebox, then use CreateWindow again to create a child window (hint use the style WM_CHILD) and create a text edit area, i belive then you can make it read only, so they can select it but not click inside the text or modify it. there might be a better way than this, and if so, someone else below me will say it im sure :).

all the styles and types of windows you can create are listed below the CreateWindow function in the msdn platform sdk, so then its simply a matter of pluggin in the right argumnets to get the results you want.

good luck

Share this post


Link to post
Share on other sites
Uh...

When you say you want the user to be able to copy the text, do you mean by pressing Ctrl+C, or do you intend to provide a "Copy Text to Clipboard" function? I'd recommend the latter as it's so much more elegant.

Create your window with the WS_POPUP (for a captionless window) or WS_CHILD window styles. Place the text in a label (use the Designer [VS 7.x+] or Resource Editor [VS 4+]), and then use the SetClipboardData API to respond to the button click event and place the label text on the clipboard.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I wrote a code that displays window from a dialog and the source code should looks like that:

#include

#include
#include

#include "..\resource.h"

HINSTANCE hInst;

HWND MainWindow;

char* ClassName = "klasa";

LRESULT CALLBACK MainWndProc ( HWND, UINT, WPARAM, LPARAM );
BOOL CALLBACK MainWndProc1 ( HWND, UINT, WPARAM, LPARAM );

int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE, LPSTR, int ) {
MSG uMsg;

WNDCLASS WndCl;

WndCl.style = CS_HREDRAW | CS_VREDRAW;
WndCl.hInstance = hInstance;
WndCl.lpszClassName = ClassName;
WndCl.lpfnWndProc = MainWndProc;
WndCl.hIcon = LoadIcon ( NULL, IDI_APPLICATION );
WndCl.hCursor = LoadCursor ( NULL, IDC_ARROW );
WndCl.cbClsExtra = 0;
WndCl.cbWndExtra = 0;
WndCl.hbrBackground = ( HBRUSH ) ( COLOR_WINDOW + 1 );

if ( !RegisterClass ( &WndCl ) )
return 0;

hInst = hInstance;

InitCommonControls ( );

DialogBox ( hInst, ( LPCTSTR ) IDD_ZAKLADKA, MainWindow, ( DLGPROC ) MainWndProc1 );

ShowWindow ( MainWindow, SW_NORMAL );
UpdateWindow ( MainWindow );

while ( GetMessage ( &uMsg, NULL, 0, 0 ) ) {
if ( !IsDialogMessage ( MainWindow, &uMsg ) ) {
TranslateMessage ( &uMsg );
DispatchMessage ( &uMsg );
}
}

return ( uMsg.wParam );
}

LRESULT CALLBACK MainWndProc ( HWND Window, UINT uMsg, WPARAM wParam, LPARAM lParam ) {
switch ( uMsg ) {
case WM_COMMAND:
switch ( LOWORD ( wParam ) ) {
case ID_ABOUT:
MessageBox ( NULL, "", "", MB_OK );
break;
}
case WM_CLOSE:
EndDialog ( Window, LOWORD ( wParam ) );
PostQuitMessage ( 0 );
return TRUE;
}

return DefWindowProc ( Window, uMsg, wParam, lParam );
}

BOOL CALLBACK MainWndProc1 ( HWND Window, UINT uMsg, WPARAM wParam, LPARAM lParam ) {
switch ( uMsg ) {
case WM_INITDIALOG: {
return 0;

case WM_COMMAND:
switch ( LOWORD ( wParam ) ) {
}
break;

case WM_CLOSE:
EndDialog ( Window, LOWORD ( wParam ) );
PostQuitMessage ( 0 );
return TRUE;
}

return FALSE;
}

But in this code i found one bug. i cannot handle accelerators and i don`t know why.

Share this post


Link to post
Share on other sites
Ok, I now have a popup window (dialog box) with an Ok button and a read only edit box.
How do I make the Ok button close the window and how do I write a message into the readonly edit box?

Share this post


Link to post
Share on other sites
Easy. RTFM.

I mean, do you know anything about Windows programming? Are you willing to expend any effort to learn - or at least try - to do things yourself, or do you just want us to write the program for you?

Hint: WM_MESSAGE, BN_CLICKED. MSDN.

Share this post


Link to post
Share on other sites
Quote:
Original post by The C modest god
I have been able to make the Ok button close the window,
but how do I insert text to the edit box?

SetDlgItemText(), which just wraps WM_SETTEXT - Which is what Oluseyi meant

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!