Click here to Skip to main content
16,006,845 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Custom Controls in MFC Pin
Cedric Moonen19-May-06 7:14
Cedric Moonen19-May-06 7:14 
QuestionRe: Custom Controls in MFC Pin
David Crow19-May-06 7:18
David Crow19-May-06 7:18 
AnswerRe: Custom Controls in MFC Pin
Laxman Auti19-May-06 18:41
Laxman Auti19-May-06 18:41 
QuestionHow do I get data from a toolbar to a dialog? Pin
Chris Corben19-May-06 6:06
Chris Corben19-May-06 6:06 
AnswerRe: How do I get data from a toolbar to a dialog? Pin
Kiran Kumar Singani20-May-06 2:19
Kiran Kumar Singani20-May-06 2:19 
GeneralRe: How do I get data from a toolbar to a dialog? Pin
Chris Corben20-May-06 2:51
Chris Corben20-May-06 2:51 
Questiontoolbar stacking problem Pin
Victor Monteverde19-May-06 4:53
Victor Monteverde19-May-06 4:53 
QuestionGdi Multiple Window Problem Pin
Diego.Martinez19-May-06 4:36
Diego.Martinez19-May-06 4:36 
Hi:

Im using GDI to draw some images on a window.
The images vary according to the lParam I pass to the Window Procedure of the DialogBox.
The problem is:

when I draw more than one window, the procedure applies to ALL of the Dialogs that I could have opened.

This is a real problem, because the windows MUST maintain the info after another appears, but it doesn´t. What did i do wrong?

BOOL CALLBACK AlertaDlg(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{

(...) //a lot of Variable Declarations

switch(msg)
{

case WM_INITDIALOG:

desfasex=5*num_alarmas;
desfasey=5*num_alarmas;


BringWindowToTop(hwnd);
SetActiveWindow(hwnd);
hwndOwner = GetDesktopWindow();
GetWindowRect(hwndOwner, &rcOwner);
GetWindowRect(hwnd, &rcDlg);
CopyRect(&rc, &rcOwner);


OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
OffsetRect(&rc, -rc.left, -rc.top);
OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);

sprintf(cuadro,"--");
mapset=FALSE;
planta=-1;

/*
Here i catch the info of the LPARAM, is a struct with some info about the drawings.
*/

if(lParam!=0)
{
msg_params=(msg_param *)lParam;

if (strlen(msg_params->cuadro)>0)
{
ptpuerta.x=msg_params->ptpuerta.x;
ptpuerta.y=msg_params->ptpuerta.y;

sprintf(cuadro,"%s",msg_params->cuadro);
mapset=(msg_params->mapa==1);

img_cuadro=msg_params->img_cuadro;
planta=msg_params->planta;

}
}



SetWindowPos(hwnd,HWND_TOP,(rc.right / 2)+desfasex,rcOwner.top + (rc.bottom / 2)+desfasey,0, 0, SWP_NOSIZE);


num_alarmas++;
return 0;

case WM_PAINT:

hbmp_alarma=(HBITMAP)LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ALERTA));

hbrush=CreateSolidBrush(RGB(255,0,0));

hwndItem=hwnd;

hDC = BeginPaint(hwndItem, &ps);
memHDC= CreateCompatibleDC(hDC);


SelectObject(memHDC, hbmp_alarma);
BitBlt(
hDC, //HDC hdcDest, // manipulador del contexto de dispositivo destino
10, //int nXDest, // coordenada x de la esquina superior izquierda del rectángulo de destino
10, //int nYDest, // coordenada y de la esquina superior izquierda del rectángulo de destino
600, //int nWidth, // anchura del rectángulo de destino
400, //int nHeight, // altura del rectángulo de destino
memHDC, //HDC hdcSrc, // manipulador de contexto de dispositivo de origen
0, //int nXSrc, // coordenada x de la esquina superior izquierda del rectángulo de origen
0, //int nYSrc, // coordenada y de la esquina superior izquierda del rectángulo de origen //para cliping
SRCCOPY //DWORD dwRop // código de operación de rastreo
);

switch(planta)
{
case 1:
hPlanta=(HBITMAP)LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_PLANTA1));
break;
case 2:
hPlanta=(HBITMAP)LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_PLANTA2));
break;
case 3:
hPlanta=(HBITMAP)LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_PLANTA3));
break;
default:
hPlanta=(HBITMAP)LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_PLANTA1));
break;
}

switch(img_cuadro)
{
case 1:
hCuadro=(HBITMAP)LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_CUADRO1));
break;
case 2:
hCuadro=(HBITMAP)LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_LAVANDERA));
break;
default:
hCuadro=(HBITMAP)LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_CUADRO1));
break;
}

if (mapset==true)
{
//------------------------------------------- CUADRO
SelectObject(memHDC, hPlanta);
SetStretchBltMode(
hDC, // handle to DC
COLORONCOLOR // bitmap stretching mode
);

x=130;
y=90;

StretchBlt(
hDC,
0+x,
0+y,
240,
180,
memHDC,
0,
0,
400,
250,
SRCCOPY);

//------------------------------------------- MAPA
SelectObject(memHDC, hCuadro);
SetStretchBltMode(
hDC, // handle to DC
COLORONCOLOR // bitmap stretching mode
);

x=130+240;
y=90;

StretchBlt(
hDC,
x+0,
y+0,
320,
240,
memHDC,
0,
0,
320,
240,
SRCCOPY);



SelectObject(hDC,hbrush);
Rectangle(hDC,ptpuerta.x-5,ptpuerta.y-5,ptpuerta.x+5,ptpuerta.y+5);


txt_coord.x=150;
txt_coord.y=290;
}
else
{
txt_coord.x=150;
txt_coord.y=90;
}


SetBkMode(hDC, TRANSPARENT);
SetTextColor(hDC, RGB(100,100,120));

SelectObject(hDC,hfuente);

GetTextMetrics(hDC,&lptextmetrics); //recibimos sus valores en lbtextmetrics

sprintf(s,"OBRA:");
TextOut(hDC, txt_coord.x, txt_coord.y+lptextmetrics.tmHeight, s,strlen(s));

SelectObject(hDC,hfuenteItalica);
SetTextColor(hDC, RGB(100,100,120));
sprintf(s,"%s",cuadro);
TextOut(hDC, txt_coord.x, txt_coord.y+lptextmetrics.tmHeight*2, s,strlen(s));



EndPaint(hwndItem, &ps);
ReleaseDC(hwnd, hDC);
DeleteDC(memHDC);
DeleteObject(hCuadro);
DeleteObject(hPlanta);
DeleteObject(hbmp_alarma);
DeleteObject(hbrush);


return 0;

case WM_CREATE:
sprintf(cuadro,"--");
Sleep(10);
UpdateWindow(hwnd);
return 0;
case WM_CLOSE:
case WM_COMMAND:
num_alarmas--;
EndDialog(hwnd,0);
return 0;
}

return 0;
}

Thanks


Questionpointers question Pin
Mridang Agarwalla19-May-06 3:53
Mridang Agarwalla19-May-06 3:53 
AnswerRe: pointers question Pin
Cedric Moonen19-May-06 3:57
Cedric Moonen19-May-06 3:57 
AnswerRe: pointers question Pin
Steen Krogsgaard19-May-06 3:58
Steen Krogsgaard19-May-06 3:58 
AnswerRe: pointers question Pin
Laxman Auti19-May-06 4:00
Laxman Auti19-May-06 4:00 
AnswerRe: pointers question Pin
Mridang Agarwalla19-May-06 4:31
Mridang Agarwalla19-May-06 4:31 
AnswerRe: pointers question Pin
knoxplusplus23-May-06 7:31
knoxplusplus23-May-06 7:31 
QuestionExporting variables from DLL Pin
Cyber Friend19-May-06 3:49
Cyber Friend19-May-06 3:49 
AnswerRe: Exporting variables from DLL Pin
Laxman Auti19-May-06 3:55
Laxman Auti19-May-06 3:55 
GeneralRe: Exporting variables from DLL Pin
Steen Krogsgaard19-May-06 4:04
Steen Krogsgaard19-May-06 4:04 
GeneralRe: Exporting variables from DLL Pin
Cyber Friend19-May-06 5:44
Cyber Friend19-May-06 5:44 
GeneralRe: Exporting variables from DLL Pin
Nibu babu thomas19-May-06 18:39
Nibu babu thomas19-May-06 18:39 
GeneralRe: Exporting variables from DLL Pin
Steen Krogsgaard21-May-06 20:55
Steen Krogsgaard21-May-06 20:55 
QuestionRe: Exporting variables from DLL Pin
Nibu babu thomas19-May-06 18:36
Nibu babu thomas19-May-06 18:36 
AnswerRe: Exporting variables from DLL Pin
Hamid_RT19-May-06 19:21
Hamid_RT19-May-06 19:21 
AnswerRe: Exporting variables from DLL Pin
Rick York19-May-06 20:42
mveRick York19-May-06 20:42 
QuestionHow to check if a user has entered a correct password Pin
e-DJ19-May-06 3:02
e-DJ19-May-06 3:02 
AnswerRe: How to check if a user has entered a correct password Pin
Laxman Auti19-May-06 3:09
Laxman Auti19-May-06 3:09 

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.