|
Each of your controls should receive the WM_PAINT message automatically. It is up to Windows to decide when to redraw a control, so you do not need to post this message. If you want to invoke redrawing of controls, you can use InvalidateRect or InvalidateControl functions.
|
|
|
|
|
Hi ,
Can I create SDL(simple Directmedia layer) With som other window control on the single window ....(Either in MFC/win32)
But below is the sample code which creates a window and just place a SDL screen on it. but what i need is to place some button(like play,stop,pause) beside the sdl screen in the same window...
/* Simple program: Fill a colormap with gray and stripe it down the screen */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#ifdef WIN32
# include <windows.h>
# include "Resource.h"
static HWND g_hwnd;
#endif /* WIN32 */
#include "SDL.h"
#ifdef TEST_VGA16 /* Define this if you want to test VGA 16-color video modes */
#define NUM_COLORS 16
#else
#define NUM_COLORS 256
#endif
HWND g_hToolbar = NULL,hWndToolbox;
/******************************************************************************/
LRESULT CALLBACK ToolboxProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case WM_INITDIALOG:
return TRUE;
}
return FALSE;
}
/**********************************************************************************/
BOOL CALLBACK ToolDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
switch(Message)
{
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_PRESS:
MessageBox(hwnd, "Hi!", "This is a message",
MB_OK | MB_ICONEXCLAMATION);
break;
case IDC_OTHER:
MessageBox(hwnd, "Bye!", "This is also a message",
MB_OK | MB_ICONEXCLAMATION);
break;
}
break;
default:
return FALSE;
}
return TRUE;
}
/SDL_Surface *CreateScreen(Uint16 w, Uint16 h, Uint8 bpp, Uint32 flags)
{
SDL_Surface *screen;
int i;
SDL_Color palette[NUM_COLORS];
Uint8 *buffer;
/* Set the video mode */
screen = SDL_SetVideoMode(320, 240, bpp, flags);
if ( screen == NULL ) {
fprintf(stderr, "Couldn't set display mode: %s\n",
SDL_GetError());
return(NULL);
}
fprintf(stderr, "Screen is in %s mode\n",
(screen->flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed");
/* Set a gray colormap, reverse order from white to black */
for ( i=0; i<num_colors; ++i="" )="" {
palette[i].b="(NUM_COLORS-1)-i" *="" (256="" num_colors);
palette[i].g="(NUM_COLORS-1)-i" num_colors);
palette[i].r="(NUM_COLORS-1)-i" num_colors);
}
sdl_setcolors(screen,="" palette,="" 0,="" num_colors);
="" set="" the="" surface="" pixels="" and="" refresh!=""
if="" (="" sdl_locksurface(screen)="" <="" 0="" {
fprintf(stderr,="" "couldn't="" lock="" display="" surface:="" %s\n",
sdl_geterror());
return(null);
}
buffer="(Uint8" *)screen-="">pixels;
for ( i=0; i<screen->h; ++i ) {
memset(buffer,(i*(NUM_COLORS-1))/screen->h, screen->w);
buffer += screen->pitch;
}
SDL_UnlockSurface(screen);
SDL_UpdateRect(screen, 0, 0, 0, 0);
return(screen);
}
#ifdef WIN32
LRESULT CALLBACK graywinWindowProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam) {
SDL_Event event;
switch(uMsg) {
case WM_COMMAND: /* LOWORD find exact event */
switch(LOWORD(wParam)) {
case ID_QUIT :
event.type = SDL_QUIT;
SDL_PushEvent(&event);
break;
case ID_DIALOG_SHOW:
ShowWindow(g_hToolbar, SW_SHOW);
break;
case ID_DIALOG_HIDE:
ShowWindow(g_hToolbar, SW_HIDE);
break;
}
break;
case WM_CREATE:
g_hToolbar = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_TOOLBAR),
hwnd, ToolDlgProc);
if(g_hToolbar != NULL)
{
ShowWindow(g_hToolbar, SW_SHOW);
}
else
{
MessageBox(hwnd, "CreateDialog returned NULL", "Warning!",
MB_OK | MB_ICONINFORMATION);
}
break;
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
break;
}
return 1;
}
int init_win32_window(HINSTANCE hInst, int width, int height) {
MSG msg;
char windowid[100];
WNDCLASSEX wcex;
RECT rect;
ZeroMemory(&wcex, sizeof(wcex));
wcex.cbSize = sizeof(wcex);
wcex.style = CS_HREDRAW;
wcex.lpfnWndProc = graywinWindowProc;
wcex.hInstance = hInst;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON));
wcex.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
//wcex.lpszMenuName = MAKEINTRESOURCE(IDR_MENU);
wcex.lpszClassName = "Mainframe";
if (!RegisterClassEx(&wcex)) {
MessageBox(NULL, "could not register class", "Error", MB_ICONERROR);
return 0;
}
ZeroMemory(&rect, sizeof(RECT));
rect.right = width ;
rect.bottom = height +height;
// AdjustWindowRectEx(&rect, WS_OVERLAPPEDWINDOW, TRUE, 0);
g_hwnd = CreateWindowEx(
WS_EX_STATICEDGE ,
"Mainframe",
"SDL Window",
0 ,
CW_USEDEFAULT,
CW_USEDEFAULT,
abs(rect.left) + rect.right,
abs(rect.top) + rect.bottom ,
NULL,
LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU)),
hInst,
NULL);
if (!g_hwnd) {
MessageBox(NULL, "could not create window", "Error", MB_ICONERROR);
return 0;
}
// Create a child window based on the available dialog box
hWndToolbox = CreateDialog(hInst,
MAKEINTRESOURCE(IDD_TOOLBOX_DLG),
g_hwnd,
(DLGPROC)ToolboxProc);
ShowWindow (hWndToolbox, SW_SHOW);
ShowWindow(g_hwnd ,SW_SHOWNORMAL );
while (GetMessage(&msg,NULL, 0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
ShowWindow(g_hwnd, SW_SHOWDEFAULT );
UpdateWindow(g_hwnd);
strcpy(windowid, "SDL_WINDOWID=");
_ltoa((long)g_hwnd, windowid + 13, 10);
_putenv(windowid);
return 1;
}
#endif /* WIN32 */
int main(int argc, char *argv[])
{
SDL_Surface *screen = NULL;
Uint32 videoflags;
int done;
SDL_Event event;
Uint16 width, height;
Uint8 bpp;
/* See if we try to get a hardware colormap */
width = 320;
height = 240;
bpp = 8;
videoflags = SDL_SWSURFACE;
# ifdef WIN32
init_win32_window(GetModuleHandle(NULL), width, height);
# endif
//#ifdef XX
/* Initialize SDL */
if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
exit(1);
}
// Set a video mode
screen = CreateScreen(width, height, bpp, videoflags);
if ( screen == NULL ) {
exit(2);
}
// Wait for a keystroke/
done = 0;
while ( !done && SDL_WaitEvent(&event) ) {
switch (event.type) {
case SDL_QUIT:
done = 1;
break;
default:
break;
}
}
SDL_Quit();
//#endif
return(0);
}
Manjunath S
GESL
Bangalore
|
|
|
|
|
I already asked you this question but I will ask again (maybe you will stop flooding the forums): what do you want to achieve exactly by mixing MFC (which not at all the case in your example) and SDL ? I already worked with SDL so I know how it works and how to use it. Basically, mixing SDL and MFC doesn't sound like a good idea. If you want to use it to manage events, then forget about it, because MFC won't let you easily manage that. If the purpose is only to paint a SDL surface in a MFC window, maybe this link[^] could be usefull.
But from what I see, you don't have any experience with MFC or win32 (this code looks like cut and paste). I strongly suggest you to learn that first (which could be time consuming).
Now, if you want to have a GUI system to work in cooperation with SDL, then I suggest you that you take a look at CEGUI[^] (as I already said previously, but without success).
And please, stop flooding the forums with the same question over and over again, unless you provide more information about what you are trying to achieve exactly.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Can i get any sample code for GUI system to work in cooperation with SDL...
It helps me a lot
Thanking you
Manjunath S
|
|
|
|
|
Geez, can't you simply read what I've posted ? It's incredible !!
I also asked you for more information, if you don't want to spend some time in describing your problem, then, there is no solution for you.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Hi,
well,What i need is a SDL screen in MFC/Win32 application ,with button beside that screen , so that by pressing button(like play,pause,stop) i can call sdl function to act according on sdl screen...This screen display images captured by cam. we have Back end code of SDL.But i need one Window with GUI interface ....
Thanking you
Manjunath S
GESL
Bangalore
|
|
|
|
|
Manjunath S wrote: This screen display images captured by cam
This is ridiculous. You use SDL just to display images from a camera ? Why don't you use another technique (don't know which one but this looks like a very bad solution to me).
Manjunath S wrote: well,What i need is a SDL screen in MFC/Win32 application ,with button beside that screen , so that by pressing button(like play,pause,stop) i can call sdl function to act according on sdl screen
Did you even bother to follow the links I gave you ? One of the link describes how to render SDL surfaces in a win32 environment.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Hi,
Can I get any other solution for this(i.e SDL in MFC/Win32).If there please inform me.
Can i get link once again, Please explain me how to create buttons beside that screen.
Thanking you
Manjunath S
GESL
Bangalore
|
|
|
|
|
Manjunath S wrote: Can i get link once again
that's stupid... scroll the page up and reach Cedric previous posts to see the links
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
I am trying to get the Microsoft Windows installation key (the serial number) in my VC6 C++ program. The key can be found from XP->Control Panel->System->General. For example, the key on my computer is "55276-OEM-0011901-00102". Does anybody know how to get the string in C++ program?
Thanks in advance
|
|
|
|
|
//how about using GetVolumeInformation() .
Viorel is correct.I checked it with MSDN
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
-- modified at 9:54 Tuesday 6th June, 2006
|
|
|
|
|
I think GetVolumeInformation actually returns another kind of information -- the disk's serial number (the same which is shown by the vol command).
|
|
|
|
|
If you are familiar with Windows Management Instrumentation (WMI), then you can obtain the Serial Number through the Win32_OperatingSystem WMI class, which has the SerialNumber data member as a string.
See Win32_OperatingSystem class and WMI-related information.
|
|
|
|
|
ytsau wrote: Does anybody know how to get the string in C++ program?
Just read it from the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks for all the replies!
How do I read the registry? Can you show me the actual C code?
Thanks again!
|
|
|
|
|
ytsau wrote: How do I read the registry?
Use RegQueryValueEx() .
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks a lot!
Here is the actual code I figured out to access the ProductID:
UCHAR buf[256];
ULONG size = 256;
ULONG type = REG_SZ;
HKEY hKey;
RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &hKey);
RegQueryValueEx(hKey, L"ProductId", NULL, &type, buf, &size );
RegCloseKey(hKey);
|
|
|
|
|
Great. The only change I would suggest is:
ULONG size = sizeof(buf); That way if you need to change the size of buf , you only have to do it in one spot.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: Just read it from the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId
It should be considered that another sibling key path -- "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\ProductId" -- seems to be more version-independent.
|
|
|
|
|
Viorel. wrote: It should be considered that another sibling key path -- "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\ProductId" -- seems to be more version-independent.
The General tab of the System Properties dialog does not look at that key.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi
I am working with dialog based application. Below is the snapshot of first part of dialog class of my project.
class CFileSenderDlg : public CDialog<br />
{<br />
public:<br />
CFileSenderDlg(CWnd* pParent = NULL);
void setStatus(CString);
enum { IDD = IDD_FILESENDER_DIALOG };<br />
CString filePath;<br />
CString status;<br />
<br />
protected:<br />
virtual void DoDataExchange(CDataExchange* pDX);
and so on.
But i am recieving an error on
enum { IDD = IDD_FILESENDER_DIALOG };
And that is
error C2065: 'IDD_FILESENDER_DIALOG' : undeclared identifier
error C2057: expected constant expression
Can anyone please tell me why this error occurs.
Thank you
We Believe in Excellence
www.aqueelmirza.cjb.net
-- modified at 8:34 Tuesday 6th June, 2006
|
|
|
|
|
wrote:
error C2065: 'IDD_FILESENDER_DIALOG' : undeclared identifier
Can anyone please tell me why this error occurs.
include "resource.h" file
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Thanks for responding. I tried it but now it is displaying "Debug Assertion Failed" dialog. and when i try to debug it, it is at following line in afxwin1.inl
_AFXWIN_INLINE HINSTANCE AFXAPI AfxGetResourceHandle()<br />
{ ASSERT(afxCurrentResourceHandle != NULL);
Can you please tell me why it is.
Thank you
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
This is just a guess, but are you trying to create the dialog in some other class's constructor? (My guess is the CWinApp-derived one). If that is the case, then put it elsewhere.
this is this.
|
|
|
|
|
how to create your class?
whitesky
|
|
|
|
|