/**************/ /* desktop.c */ /****************************************************************************** PROGRAM: desktop.c Windows: Win 3.1 ( & WIN32 ei testattu ) PURPOSE: Tekee ohjelmalle taustakuvan, joka täyttää koko kuvaruudun. PROJECT: ALI\desktop.c ALI\bitmap.c ALI\fontit.c ALI\autotw.c ALI\tabhand.c ALI\printw.c Editor: Vesa Lappalainen 24.9.1995 Muutokset: Ini-tiedosto: [Desktop] ; Taustaan liittyvät asiat desktop=1 ; Tuleeko tausta vaiko ei UpdateText=1 ; Päivitetäänkö taustan tekstiä jatkuvasti color=ff0000 ; taustan väri RGB NoFontChange=0 ; Saako fontin vaihtaa ajon aikana [Desktop-n] ; n=0-, yhden taustatekstin tiedot x=30 ; Tekstin alkupaikka x y=40 ; tekstin alkupaikka y text=Text-0 ; Mikä [..] kohta tekstiä tulostetaan font=0 ; Mitä fonttia käytetään tulostamiseen [Text-0] ; Taustan teksti 0 WinLogin %version%= [Text-1] ; Taustan teksti 1 = = Anna tunnuksesi koneessa %host%= [FONT-Desktop-n] ; n = 0-5 ; Taustan tekstissä käytettävä fontti, ; tämä on helpointa muuttaa painamalla ; 0 - 5 kun tausta on aktiivinen [AUTOT] ; Liikkuvat bittikuvat, ks. autotw.c ------------------------------------------------------------------------------ Aliohjelmat ja tyypit ------------------------------------------------------------------------------ typedef char *(*tDTStringChg)(char *s, int ms, int len); - ennen tulostusta kutsuttavan funktion tyyppi HWND CheckDesktop(HWND hWnd,const char *ini,tDTStringChg stChg); - aliohjelma tutkii on ini-tiedostossa pyydetty taustaa ja jos on, niin alustaa taustaikkunan ja palautta sen kahvan. stChg on funktio-osoitin, jota kutsutaan merkkijonolle ennen taustatekstin tulostamista. Näin tausta tekstiin voidaan laittaa esim. omia muuttujia, jotka stChg-funktio sitten korvaa. Tätä aliohjelmaa kutsutaan esim. WM_CREATE tai WM_INITDIALOG viestien käsittelyssä. int DesktopUpdate(HWND hWnd); - jos ohjelman "muuttujissa" on tapahtunut muutoksia, jotka pitäisi saada näkymään myös taustakuvassa, kutsutaan tätä, jolloin tausta piirrteään uudestaan (jos [Desktop] UpdateText=1). int DestroyDesktop(HWND hWndBK); - ohjelman lopuksi hävitetään taustan alustamat tiedot ******************************************************************************/ #include #include #include #include #include #include #include //#include "mjonot.h" #include "tabhand.h" #include "fontti.h" /* f */ #include "printw.h" #include "autot.h" #include "desktop.h" #include "bitmap.h" #define N_S(s) s,sizeof(s) typedef struct { tFontChange f; const char *ini; COLORREF bkcolor; tDTStringChg stChg; int DesktopUpdateText; int active; tbmBitmapCache bc; } tDesktop; static int winIDs[] = { '0',0,'1',0,'2',0,'3',0,'4',0,'5',0,0 }; /* f */ static tDesktop GD = {{"DeskTop",winIDs, NULL}}; /* f */ /*****************************************************************************/ static void setwcb(tCreWndSt *c) { c->wc.hbrBackground = CreateSolidBrush(GD.bkcolor); c->cs.style = WS_POPUP; } /*****************************************************************************/ TWINDOWPROC(bkMsgTbl,BkWndProc) /*****************************************************************************/ int DesktopUpdate(HWND hWndBK) { if ( GD.active == 0 ) return 0; if ( hWndBK == NULL || GD.DesktopUpdateText == 0 ) return 0; InvalidateRect(hWndBK,NULL,TRUE); return 0; } /*****************************************************************************/ HWND CheckDesktop(HWND hWnd,const char *ini,tDTStringChg stChg) { char s[100]; HWND hWndBK; int r=0,g=0,b=0; if ( GetPrivateProfileInt("Desktop","Desktop",0,ini) == 0 ) return NULL; GD.ini = ini; GetPrivateProfileString("Desktop","color","808080",N_S(s),ini); sscanf(s,"%2x%2x%2x",&r,&g,&b); GD.bkcolor = RGB(r,g,b); GetPrivateProfileString("Desktop","Title","WinLogin",N_S(s),ini); hWndBK = DoClassWindowCmd(GetWindowInstance(hWnd),"WinLogBgCls",NULL, NULL, s, BkWndProc, 0,SW_MAXIMIZE,setwcb); GD.stChg = stChg; GD.DesktopUpdateText = GetPrivateProfileInt("Desktop","UpdateText",0,ini); alusta_autot(NULL,hWndBK,ini); alusta_fontit(hWndBK,GD.ini,&GD.f); /* f */ GD.active = 1; return hWndBK; } /*****************************************************************************/ int DestroyDesktop(HWND hWndBK) { if ( GD.active == 0 ) return 0; if ( hWndBK == NULL ) return 0; DestroyWindow(hWndBK); return 0; } /*****************************************************************************/ static int DoDesktopPrint(HDC hDC,int nr) { tOneFont *f; int len; int i,x,y; char s[1000]; char section[20],text[40],font[3],bitmapfile[100]; sprintf(section,"Desktop-%d",nr); x = GetPrivateProfileInt(section,"x",10,GD.ini); y = GetPrivateProfileInt(section,"y",10,GD.ini); GetPrivateProfileString(section,"text","",N_S(text),GD.ini); if ( text[0] ) { len = GetPrivateProfileString(text,NULL,"",N_S(s),GD.ini); if ( len == 0 ) return 0; if ( GD.stChg ) GD.stChg(N_S(s),len); else for (i=0; ihDC,i) ) break; return 0; } static EVENT WM_destroy(tMSGParam *msg) { if ( GD.active == 0 ) return 0; poista_fontit(msg->hWnd,GD.ini,&GD.f); /* f */ bmDeleteBitmapCache(&GD.bc); GD.active = 0; return 0; } static EVENT WM_char(tMSGParam *msg) { if ( GD.active == 0 ) return 0; if ( GetPrivateProfileInt("Desktop","nofontchange",0,GD.ini) ) return 0; if ( vaihda_fontit_id(msg->hWnd,&GD.f,msg->wParam) ) return 1; /* f */ InvalidateRect(msg->hWnd,NULL,TRUE); return 0; } /*****************************************************************************/ static tMSGEntry bkMsgTbl[] = { { WM_PAINT , DoC , DoC , WM_paint, MAKE_DC }, { WM_DESTROY , DoC , DoC , WM_destroy }, { WM_CHAR , DoC , DoC , WM_char }, { 0 } };