Click here to Skip to main content
15,899,025 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionA question about sdi multiview Pin
Member 20063986-Jun-06 6:07
Member 20063986-Jun-06 6:07 
QuestionReading pdf file [modified] Pin
maharaja pandian6-Jun-06 4:46
maharaja pandian6-Jun-06 4:46 
AnswerRe: Reading pdf file [modified] Pin
Rage6-Jun-06 4:48
professionalRage6-Jun-06 4:48 
AnswerRe: Reading pdf file [modified] Pin
David Crow6-Jun-06 6:53
David Crow6-Jun-06 6:53 
AnswerRe: Reading pdf file [modified] Pin
Hamid_RT6-Jun-06 19:29
Hamid_RT6-Jun-06 19:29 
QuestionHow to display another control on my coustom control? Pin
old_dustman6-Jun-06 4:45
old_dustman6-Jun-06 4:45 
AnswerRe: How to display another control on my coustom control? Pin
Viorel.6-Jun-06 4:57
Viorel.6-Jun-06 4:57 
Questionwindow and some other class in same window Pin
Manjunath S6-Jun-06 4:08
Manjunath S6-Jun-06 4:08 
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
AnswerRe: window and some other class in same window Pin
Cedric Moonen6-Jun-06 4:33
Cedric Moonen6-Jun-06 4:33 
QuestionRe: window and some other class in same window Pin
Manjunath S6-Jun-06 4:46
Manjunath S6-Jun-06 4:46 
AnswerRe: window and some other class in same window Pin
Cedric Moonen6-Jun-06 4:55
Cedric Moonen6-Jun-06 4:55 
QuestionRe: window and some other class in same window Pin
Manjunath S6-Jun-06 6:32
Manjunath S6-Jun-06 6:32 
AnswerRe: window and some other class in same window Pin
Cedric Moonen6-Jun-06 6:37
Cedric Moonen6-Jun-06 6:37 
QuestionRe: window and some other class in same window Pin
Manjunath S6-Jun-06 6:52
Manjunath S6-Jun-06 6:52 
GeneralRe: window and some other class in same window Pin
toxcct6-Jun-06 21:44
toxcct6-Jun-06 21:44 
QuestionHelp! How to get Windows installation key Pin
ytsau6-Jun-06 3:33
ytsau6-Jun-06 3:33 
AnswerRe: Help! How to get Windows installation key [modified] Pin
_AnsHUMAN_ 6-Jun-06 3:39
_AnsHUMAN_ 6-Jun-06 3:39 
GeneralRe: Help! How to get Windows installation key Pin
Viorel.6-Jun-06 3:48
Viorel.6-Jun-06 3:48 
AnswerRe: Help! How to get Windows installation key Pin
Viorel.6-Jun-06 3:45
Viorel.6-Jun-06 3:45 
AnswerRe: Help! How to get Windows installation key Pin
David Crow6-Jun-06 4:11
David Crow6-Jun-06 4:11 
GeneralRe: Help! How to get Windows installation key Pin
ytsau6-Jun-06 4:18
ytsau6-Jun-06 4:18 
GeneralRe: Help! How to get Windows installation key Pin
David Crow6-Jun-06 4:30
David Crow6-Jun-06 4:30 
GeneralRe: Here is how to get Windows installation key Pin
ytsau6-Jun-06 7:14
ytsau6-Jun-06 7:14 
GeneralRe: Here is how to get Windows installation key Pin
David Crow6-Jun-06 7:29
David Crow6-Jun-06 7:29 
GeneralRe: Help! How to get Windows installation key Pin
Viorel.6-Jun-06 4:33
Viorel.6-Jun-06 4:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.