Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Hintergrund von STATIC-Fenstern dauerhaft einfärben

Empfohlene Antworten

Hallöchen,

ich versuche den Hintergrund mehrerer STATIC-Fenster einzufärben. Dazu zeichne ich den Hintergrund der Fenster wenn die WM_PAINT Message gespeichert wird.

Wenn ich das Fenster jedoch verschiebe oder an den Rändern ziehe, zeichnet es die Farbe nicht mehr nach. Dann werden die einzelnen Fenster einfach weis. Ich habe aber absolut keine Ahnung warum das so ist.

hier mal die WM_CREATE und die WM_PAINT Messages. Die Handler und die PAINTSTRUCT habe ich global deklariert, damit sie mir dauerhaft zur Verfügung stehen, und nicht nach dem Beenden der Funktion gelöscht werden.

        case WM_CREATE:{
unsigned int l=0,h=0,ll=50,lh=50,n=1;
for(int i=0; i<tmpplg.getSizeX();i++){

for(int j=0; j<tmpplg.getSizeY();j++){
hwndplg[i][j]=CreateWindow(TEXT("STATIC"),TEXT(""),WS_VISIBLE | WS_CHILD | WS_BORDER, l,h,ll,lh,hwnd,(HMENU) n, NULL, NULL);
l=l+50;n++;
}
l=0;h=h+50;
}

break;
}
case WM_PAINT:{

unsigned int n=1;
HDC dcWindow[4][4];
for(int i=0;i<tmpplg.getSizeX();i++){
unsigned int l=0, h=0, ll=50, lh=50;
vector<Cell> tmpcell = tmpplg.getAllCells();
for(int j=0;j<tmpplg.getSizeY();j++){
dcWindow[i][j]=BeginPaint(hwndplg[i][j],&ps);
if(tmpcell.at(j+i*tmpplg.getSizeX()).getState()==0){

/*
GetClientRect(hwndplg[i][j],&tmprect[i][j]);

tmprect[i][j].left=l;
tmprect[i][j].top=h;
tmprect[i][j].right=ll;
tmprect[i][j].bottom=lh;
dcWindow[i][j] = GetDC(hwndplg[i][j]);

FillRect(dcWindow[i][j], &tmprect[i][j], CreateSolidBrush(RGB(255, 255, 255)));
*/
FillRect(dcWindow[i][j], &ps.rcPaint, CreateSolidBrush(RGB(255, 255, 255)));
//SendDlgItemMessage(hwnd,n,WM_CTLCOLORSTATIC,(WPARAM)dcWindow[i][j],(LPARAM)hwndplg[i][j]);
//ReleaseDC(hwndplg[i][j],dcWindow[i][j]);
//EndPaint(hwndplg[i][j],&ps);
}
if(tmpcell.at(j+i*tmpplg.getSizeX()).getState()==1){
//dcWindow[i][j]=BeginPaint(hwndplg[i][j],&ps);
/*
GetClientRect(hwndplg[i][j],&tmprect[i][j]);
tmprect[i][j].left=l;
tmprect[i][j].top=h;
tmprect[i][j].right=ll;
tmprect[i][j].bottom=lh;
dcWindow[i][j] = GetDC(hwndplg[i][j]);

FillRect(dcWindow[i][j], &tmprect[i][j], CreateSolidBrush(RGB(0, 255, 0)));
*/
FillRect(dcWindow[i][j], &ps.rcPaint, CreateSolidBrush(RGB(0, 255, 0)));
//ReleaseDC(hwndplg[i][j],dcWindow[i][j]);
//EndPaint(hwndplg[i][j],&ps);
}
if(tmpcell.at(j+i*tmpplg.getSizeX()).getState()==2){
//dcWindow[i][j]=BeginPaint(hwndplg[i][j],&ps);
/*
GetClientRect(hwndplg[i][j],&tmprect[i][j]);
tmprect[i][j].left=l;
tmprect[i][j].top=h;
tmprect[i][j].right=ll;
tmprect[i][j].bottom=lh;
dcWindow[i][j] = GetDC(hwndplg[i][j]);

FillRect(dcWindow[i][j], &tmprect[i][j], CreateSolidBrush(RGB(255, 0, 0)));
*/
FillRect(dcWindow[i][j], &ps.rcPaint, CreateSolidBrush(RGB(255, 0, 0)));

ReleaseDC(hwndplg[i][j],dcWindow[i][j]);

//EndPaint(hwndplg[i][j],&ps);
}
EndPaint(hwndplg[i][j],&ps);
n++;}

}
paint=true;
break;
}[/PHP]

Ich bin mir nicht sicher, ob es was hilft, die WM_PAINT Message halt periodisch aufzurufen, damit das Fenster immer wieder neu gezeichnet wird. Oder muss ich die WM_SIZE Message abfangen und darauf mit einem Neuzeichnen reagieren?

Wäre schön, wenn ihr mir hier nen Tipp oder einen Denkanstoß geben könntet.

mfg Astasor

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Konto

Navigation

Suchen

Suchen

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.