Example #1
0
static HRESULT drawProgressBarPart(HRESULT hr, struct drawState *s)
{
	int progress;
	LONG indeterminatePos;
	HTHEME theme;
	RECT r;
	RECT rBorder, rFill[2];
	int i, nFill;
	TEXTMETRICW tm;
	int sysColor;

	if (hr != S_OK)
		return hr;
	if (s->p->progressBarModelColumn == -1)
		return S_OK;

	progress = uiprivTableProgress(s->t, s->iItem, s->iSubItem, s->p->progressBarModelColumn, &indeterminatePos);

	theme = OpenThemeData(s->t->hwnd, L"PROGRESS");

	if (GetTextMetricsW(s->dc, &tm) == 0) {
		logLastError(L"GetTextMetricsW()");
		hr = E_FAIL;
		goto fail;
	}
	r = s->m->subitemBounds;
	// this sets the height of the progressbar and vertically centers it in one fell swoop
	r.top += (r.bottom - tm.tmHeight - r.top) / 2;
	r.bottom = r.top + tm.tmHeight;

	// TODO check errors
	rBorder = r;
	InflateRect(&rBorder, -1, -1);
	if (theme != NULL) {
		RECT crect;

		hr = GetThemeBackgroundContentRect(theme, s->dc,
			PP_TRANSPARENTBAR, PBBS_NORMAL,
			&rBorder, &crect);
		if (hr != S_OK) {
			logHRESULT(L"GetThemeBackgroundContentRect()", hr);
			goto fail;
		}
		hr = DrawThemeBackground(theme, s->dc,
			PP_TRANSPARENTBAR, PBBS_NORMAL,
			&crect, NULL);
		if (hr != S_OK) {
			logHRESULT(L"DrawThemeBackground() border", hr);
			goto fail;
		}
	} else {
		HPEN pen, prevPen;
		HBRUSH brush, prevBrush;

		sysColor = COLOR_HIGHLIGHT;
		if (s->m->selected)
			sysColor = COLOR_HIGHLIGHTTEXT;

		// TODO check errors everywhere
		pen = CreatePen(PS_SOLID, 1, GetSysColor(sysColor));
		prevPen = (HPEN) SelectObject(s->dc, pen);
		brush = (HBRUSH) GetStockObject(NULL_BRUSH);
		prevBrush = (HBRUSH) SelectObject(s->dc, brush);
		Rectangle(s->dc, rBorder.left, rBorder.top, rBorder.right, rBorder.bottom);
		SelectObject(s->dc, prevBrush);
		SelectObject(s->dc, prevPen);
		DeleteObject(pen);
	}

	nFill = 1;
	rFill[0] = r;
	// TODO check error
	InflateRect(&rFill[0], -1, -1);
	if (progress != -1)
		rFill[0].right -= (rFill[0].right - rFill[0].left) * (100 - progress) / 100;
	else {
		LONG barWidth;
		LONG pieceWidth;

		// TODO explain all this
		// TODO this should really start the progressbar scrolling into view instead of already on screen when first set
		rFill[1] = rFill[0];		// save in case we need it
		barWidth = rFill[0].right - rFill[0].left;
		pieceWidth = barWidth / indeterminateSegments;
		rFill[0].left += indeterminatePos % barWidth;
		if ((rFill[0].left + pieceWidth) >= rFill[0].right) {
			// make this piece wrap back around
			nFill++;
			rFill[1].right = rFill[1].left + (pieceWidth - (rFill[0].right - rFill[0].left));
		} else
			rFill[0].right = rFill[0].left + pieceWidth;
	}
	for (i = 0; i < nFill; i++)
		if (theme != NULL) {
			hr = DrawThemeBackground(theme, s->dc,
				PP_FILL, PBFS_NORMAL,
				&rFill[i], NULL);
			if (hr != S_OK) {
				logHRESULT(L"DrawThemeBackground() fill", hr);
				goto fail;
			}
		} else
			// TODO check errors
			FillRect(s->dc, &rFill[i], GetSysColorBrush(sysColor));

	hr = S_OK;
fail:
	// TODO check errors
	if (theme != NULL)
		CloseThemeData(theme);
	return hr;
}
Example #2
0
// funkcja okna zawieraj¹ca obs³ugê meldunków przesy³anych do okna
LRESULT CALLBACK WndProc (HWND Okno, UINT KodMeldunku, WPARAM wParam, LPARAM lParam)
{
	// deklaracja zmiennych
	static POINT Punkty[100]; // tablica klikniêæ
	static POINT Punkty2[100]; // tablica klikniêæ
    static int rozmiary[100], regiony[100];
	static int lPunktow = 0;
    static int lPunktow2 = 0;
	static int i = 50;
	static int ii=0;
	static bool leftMouse;
    static bool rightMouse;
	
	static bool negatyw = false;
	HMENU mGlowne, mPlik, mRozmiar, mKolor, mInfo;

	// obs³uga meldunku w zale¿noœci od kodu meldunku
	switch (KodMeldunku) 
	{ case WM_CREATE:  // obs³uga utworzenia okna - stworzenie menu
		mPlik = CreateMenu();
		AppendMenu(mPlik, MF_STRING, 100, "&Gong...");
		AppendMenu(mPlik, MF_SEPARATOR, 0, "");
		AppendMenu(mPlik, MF_STRING, 101, "&Koniec");
		mRozmiar = CreateMenu();
		AppendMenu(mRozmiar, MF_STRING, 103, "&Du¿e");
		AppendMenu(mRozmiar, MF_STRING, 104, "&Ma³e");
		mKolor = CreateMenu();
		AppendMenu(mKolor, MF_STRING, 105, "&Podstawowy");
		AppendMenu(mKolor, MF_STRING, 106, "&Negatyw");
		mInfo = CreateMenu();
		AppendMenu(mInfo, MF_STRING, 102, "&Autor...");
		mGlowne = CreateMenu();
		AppendMenu(mGlowne, MF_POPUP, (UINT_PTR) mPlik, "&Plik");
		AppendMenu(mGlowne, MF_POPUP, (UINT_PTR) mRozmiar, "&Rozmiar");
		AppendMenu(mGlowne, MF_POPUP, (UINT_PTR) mKolor, "&Kolor");
		AppendMenu(mGlowne, MF_POPUP, (UINT_PTR) mInfo, "&Info");
		SetMenu(Okno, mGlowne);
		DrawMenuBar(Okno);

		Punkty[lPunktow].x=200; // wype³nienie pierwszej pozycji tablicy klikniêæ
		Punkty[lPunktow].y=200;
		lPunktow++;
		InvalidateRect(Okno, NULL, TRUE); // wymuszenie meldunku WM_PAINT
		return 0;

	  case WM_COMMAND: // obs³uga wyboru opcji z menu
		switch (wParam)
		{
		case 100: if(MessageBox(Okno, "Czy wygenerowaæ gong?", "Gong", MB_YESNO) == IDYES)
					MessageBeep(0);
                  break;
		case 101: DestroyWindow(Okno); // wymuszenie meldunku WM_DESTROY
        		  break;
		case 102: MessageBox(Okno, "imiê i nazwisko: Katarzyna Wolszon\nnumer indeksu: s8133", "Student PJWSTK", MB_OK);
				  break;
		case 103: ii = 50;
				  break;
		case 104: ii = 0;
				  break;
		case 105: negatyw = false; //kolor podstawowy
				  break;
		case 106: negatyw = true; //negatyw
				  break;
		}
		return 0;
	
	  case WM_LBUTTONDOWN: // obs³uga wciœniêcia lewego przycisku myszki
		leftMouse=true;
        rightMouse=false;
		if(lPunktow >= sizeof(Punkty)/sizeof(POINT)) lPunktow = 0; // przepe³nienie tablicy klikniêæ
		Punkty[lPunktow].x = LOWORD(lParam); // zapisanie wspó³rzêdnych kursora w tablicy klikniêæ
		Punkty[lPunktow].y = HIWORD(lParam);
		rozmiary[lPunktow] = ii;
		//if (negatyw) negatywT[lPunktow] = true;
		//else negatywT[lPunktow] = false;

		lPunktow++;
		InvalidateRect(Okno, NULL, leftMouse); // wymuszenie meldunku WM_PAINT
		return 0;

	case WM_RBUTTONDOWN: // obs³uga wciœniêcia prawego przycisku myszki
        leftMouse=false;
        rightMouse=true;
        if(lPunktow2 >= sizeof(Punkty2)/sizeof(POINT)) lPunktow2 = 0; // przepe³nienie tablicy klikniêæ
        Punkty2[lPunktow2].x = LOWORD(lParam); // zapisanie wspó³rzêdnych kursora w tablicy klikniêæ
        Punkty2[lPunktow2].y = HIWORD(lParam);
        lPunktow2++;
        InvalidateRect(Okno, NULL, rightMouse); // wymuszenie meldunku WM_PAINT
        return 0;

	  case WM_PAINT: // obs³uga odœwie¿enia okna
		  {	PAINTSTRUCT Paint;
			HDC Kontekst = BeginPaint(Okno, &Paint);
			char Tekst[] = "Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon";
			POINT Wielokat1[] = {{100, 100}, {120+i, 100}, {120+i, 150+i/2}, {170+i, 100},{190+i*2, 100}, {120+i, 170+i}, {190+i*2, 280+i}, {170+i, 280+i},{120+i, 200+i+i/2}, {120+i, 280+i}, {100, 280+i}};	
			POINT Wielokat2[] = {{200+i*2, 100}, {220+i*3, 100}, {220+i*3, 260}, {260+i*3, 240},{320+i*3, 260}, {320+i*3, 100}, {340+i*4, 100}, {340+i*4, 280+i},{320+i*3, 280+i}, {260+i*3, 260+i}, {220+i*3, 280+i}, {200+i*2, 280+i}};
			POINT Wielokat1m[] = {{100, 100}, {120, 100}, {120, 150}, {170, 100},{190, 100}, {120, 170}, {190, 280}, {170, 280},{120, 200}, {120, 280}, {100, 280}};
			POINT Wielokat2m[] = {{200, 100}, {220, 100}, {220, 260}, {260, 240},{320, 260}, {320, 100}, {340, 100}, {340, 280},{320, 280}, {260, 260}, {220, 280}, {200, 280}};
				
			HBRUSH Pedzel = CreateSolidBrush(RGB(255,0,0)); // czerwony pêdzel
			HBRUSH Pedzel1 = CreateSolidBrush(RGB(0,0,255));
			HBRUSH Pedzel2 = CreateSolidBrush(RGB(0,255,255));
			HBRUSH Pedzel3 = CreateSolidBrush(RGB(255,255,0));
			HPEN Pioro2 = CreatePen(PS_SOLID, 2, RGB(0,255,255));
			HPEN Pioro3 = CreatePen(PS_SOLID, 2, RGB(255,255,0));
			SelectObject(Kontekst, GetStockObject(NULL_PEN));
			SetBkMode(Kontekst, TRANSPARENT);
			
			HRGN Region0 = CreatePolygonRgn(Wielokat1, 11, WINDING);
			HRGN Region1 =  CreatePolygonRgn(Wielokat2, 12, WINDING);
			HRGN Region2 = CreateRectRgn(0, 0, 0, 0); // pusty region
			//HRGN Region3 = CreatePolygonRgn(Wielokat1m, 11, WINDING);
			//HRGN Region4 =  CreatePolygonRgn(Wielokat2m, 12, WINDING);
			//HRGN RegionT = CreateRectRgn(0, 0, 0, 0); // pusty region
			
			for(int n=0; n<lPunktow; n++)
			{	
				
				OffsetRgn(Region0, Punkty[n].x-200, Punkty[n].y-200);
				OffsetRgn(Region1, Punkty[n].x-200, Punkty[n].y-200);
				CombineRgn(Region2, Region1, Region0, RGN_OR);
				//SelectClipRgn(Kontekst, Region2);
				//SelectObject(Kontekst, GetStockObject(WHITE_BRUSH)); // standardowy bia³y pêdzel
				//PaintRgn(Kontekst, Region2);
				//FrameRgn(Kontekst, Region2, Pedzel, 15, 15);
				SelectClipRgn(Kontekst, Region0);
				SelectObject(Kontekst, Pedzel);
				PaintRgn(Kontekst, Region0);
				SelectClipRgn(Kontekst, Region1);
				SelectObject(Kontekst, Pedzel1);
				PaintRgn(Kontekst, Region1);
				//CombineRgn(RegionT, RegionT, Region2, RGN_OR);
				SelectClipRgn(Kontekst, Region2);
				WORD Odstep = HIWORD(GetDialogBaseUnits());
				for(int y = 0; y < 850; y = y+Odstep) TextOut(Kontekst, 0, y, Tekst, strlen(Tekst));
				OffsetRgn(Region0, -Punkty[n].x+200, -Punkty[n].y+200);
				OffsetRgn(Region1, -Punkty[n].x+200, -Punkty[n].y+200);
			}

			 for(int j=0; j<lPunktow2; j++){    
				SetViewportOrgEx(Kontekst,Punkty2[j].x-500,Punkty2[j].y-400,NULL);
				SelectObject(Kontekst, Pioro2);
				Polygon(Kontekst, Wielokat1m, 11);
				SelectObject(Kontekst, Pioro3);
				Polygon(Kontekst, Wielokat2m, 12);
                

			 }

			DeleteObject(Pedzel);
			DeleteObject(Pedzel1);
			DeleteObject(Pedzel2);
			DeleteObject(Pedzel3);
			DeleteObject(Pioro2);
			DeleteObject(Pioro3);
			EndPaint(Okno, &Paint);
		}
		return 0;
  	
	  case WM_DESTROY: // obs³uga zamkniêcia okna - wygenerowanie meldunku WM_QUIT
		PostQuitMessage (0) ;
		return 0;
    
	  default: // standardowa obs³uga wszystkich pozosta³ych meldunków
		return DefWindowProc(Okno, KodMeldunku, wParam, lParam);
	}
}
Example #3
0
//--------------------------------------------------------------------------
// WindowProc() -> Processa as mensagens enviadas para o programa
//--------------------------------------------------------------------------
LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  // Variáveis para manipulação da parte gráfica do programa
  HDC hDC = NULL;
  PAINTSTRUCT psPaint;

  // Canetas e pincéis
  HPEN hPen = NULL;
  HPEN hPenOld = NULL;
  HBRUSH hBrush = NULL;
  HBRUSH hBrushOld = NULL;
  
  // Verifica qual foi a mensagem enviada
  switch(uMsg)
  {

    case WM_CREATE: // Janela foi criada
    {
      // Retorna 0, significando que a mensagem foi processada corretamente
      return(0);
    } break;
	
    case WM_PAINT: // Janela (ou parte dela) precisa ser atualizada
    {
	  // Obtém identificador do DC e preenche PAINTSTRUCT
      hDC = BeginPaint(hWnd, &psPaint);

	  // Cria e seleciona nova caneta no DC e salva caneta antiga
	  hPen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
	  hPenOld = (HPEN)SelectObject(hDC, hPen);

	  // Move “cursor invisível” para (100, 100)
	  MoveToEx(hDC, 100, 100, NULL);
	  // Desenha quatro retas, formando um losango
	  LineTo(hDC, 70, 120);
	  LineTo(hDC, 100, 140);
	  LineTo(hDC, 130, 120);
	  LineTo(hDC, 100, 100);

	  // Define pontos do losango
	  POINT ptLosango[4];
	  ptLosango[0].x = 20;
	  ptLosango[0].y = 70;
	  ptLosango[1].x = 50;
	  ptLosango[1].y = 90;
	  ptLosango[2].x = 80;
	  ptLosango[2].y = 70;
	  ptLosango[3].x = 50;
	  ptLosango[3].y = 50;

	  // Move “cursor invisível” para (50, 50)
	  MoveToEx(hDC, 50, 50, NULL);
	
	  // Desenha quatro retas formadas pelos pontos do vetor ptLosango[4],
	  // formando o losango
	  PolylineTo(hDC, ptLosango, 4);

	  // Restaura caneta antiga e deleta nova caneta
	  SelectObject(hDC, hPenOld);
	  DeleteObject(hPen);

	  // Libera DC e valida área
      EndPaint(hWnd, &psPaint);

      return(0);
    } break;

    case WM_CLOSE: // Janela foi fechada
    {
      // Destrói a janela
      DestroyWindow(hWnd);

      return(0);
    } break;
	
    case WM_DESTROY: // Janela foi destruída
    {
      // Envia mensagem WM_QUIT para o loop de mensagens
      PostQuitMessage(0);

      return(0);
    } break;

    default: // Outra mensagem
    {
      /* Deixa o Windows processar as mensagens que não foram verificadas na função */
	  return(DefWindowProc(hWnd, uMsg, wParam, lParam));
    }

  }
}
Example #4
0
File: guiwin.c Project: mbert/elvis
static void gwdraw(GUIWIN *gw, long fg, long bg, int bits, Char *text, int len)

{
    register int    i;
    GUI_WINDOW      *gwp = (GUI_WINDOW *)gw;
    COLORREF        fgc, bgc;
    HBRUSH	    hBrush, hPrevBrush;
    HPEN            hPen, hPrevPen;
    HDC		    hDC;
    HFONT           hFont;
    RECT            rect;
    int             ileft;
    int             xleft, xcenter, xright, ytop, ycenter, ybottom, radius;
    UINT	    options;

    /* Italics are slanted rightward from the bottom of the character cell.
     * We'd like for them to look slanted from the center of the characters,
     * and we can achieve that effect by shifting italic text slightly leftward.
     */
    ileft = 0;
    if ((bits & COLOR_GRAPHIC) != COLOR_GRAPHIC && (bits & COLOR_ITALIC))
        ileft = (gwp->ycsize - 3) / 6; /* just a guess */

    /* Convert fg and bg args into COLORREF values */
    fgc = (COLORREF)fg;
    bgc = (COLORREF)bg;

    /* compute the update RECT */
    rect.top = gwp->currow * gwp->ycsize;
    rect.left = gwp->curcol * gwp->xcsize + gwp->xcsize / 2;
    rect.bottom = rect.top + gwp->ycsize;
    rect.right = rect.left + gwp->xcsize * len;

    /* Get the window's DC */
    hDC = GetDC (gwp->clientHWnd);
    SetMapMode (hDC, MM_TEXT);

    /* hide caret */
    if (gwp->cursor_type != CURSOR_NONE && gwp->clientHWnd == GetFocus ())
    {
        HideCaret (gwp->clientHWnd);
        gwp->cursor_type = CURSOR_NONE;
    }

    /* graphic chars are a special case */
    if ((bits & COLOR_GRAPHIC) == COLOR_GRAPHIC)
    {
        /* Strip out the COLOR_GRAPHIC bits */
        bits &= ~COLOR_GRAPHIC;

        /* Erase the area */
#ifdef FEATURE_IMAGE
        if (normalimage && (long)bgc == colorinfo[COLOR_FONT_NORMAL].bg)
        {
            gw_erase_rect(hDC, &rect, normalimage, gwp->scrolled);
        }
        else if (idleimage && (long)bgc == colorinfo[COLOR_FONT_IDLE].bg)
        {
            gw_erase_rect(hDC, &rect, idleimage, gwp->scrolled);
        }
        else
#endif
        {
            hBrush = CreateSolidBrush (bgc);
            FillRect (hDC, &rect, hBrush);
            DeleteObject(hBrush);
        }

        /* Select the foreground color */
        hPen = CreatePen(PS_SOLID, 0, fgc);
        hPrevPen = SelectObject(hDC, hPen);

        /* Find special points in the first character cell */
        radius = gwp->xcsize / 3;
        xleft = rect.left;
        xright = xleft + gwp->xcsize;
        xcenter = (xleft + xright) / 2;
        ytop = rect.top;
        ybottom = rect.bottom;
        ycenter = (ytop + ybottom) / 2;

        /* For each graphic character... */
        for (i = 0; i < len; text++, i++)
        {
            /* Draw line segments, as appropriate for this character */
            if (strchr("123456|", *text))
            {
                MoveToEx(hDC, xcenter, ytop, NULL);
                LineTo(hDC, xcenter, ycenter);
            }
            if (strchr("456789|", *text))
            {
                MoveToEx(hDC, xcenter, ycenter, NULL);
                LineTo(hDC, xcenter, ybottom);
            }
            if (strchr("235689-", *text))
            {
                MoveToEx(hDC, xleft, ycenter, NULL);
                LineTo(hDC, xcenter, ycenter);
            }
            if (strchr("124578-", *text))
            {
                MoveToEx(hDC, xcenter, ycenter, NULL);
                LineTo(hDC, xright, ycenter);
            }
            if (*text == 'o')
            {
                Arc(hDC, xcenter - radius, ycenter - radius,
                    xcenter + radius, ycenter + radius,
                    xcenter - radius, ycenter,  xcenter - radius, ycenter);
            }
            if (*text == '*')
            {
                HBRUSH	oldbrush, newbrush;
                newbrush = CreateSolidBrush(fgc);
                oldbrush = SelectObject(hDC, newbrush);
                Pie(hDC, xcenter - radius, ycenter - radius,
                    xcenter + radius, ycenter + radius,
                    xcenter - radius, ycenter,  xcenter - radius, ycenter);
                SelectObject(hDC, oldbrush);
                DeleteObject(newbrush);
            }

            /* Advance the points to the next cell */
            xleft = xright;
            xcenter += gwp->xcsize;
            xright += gwp->xcsize;
        }

        /* Restore foreground color to its previous value, so we can delete
         * the local hPen object.
         */
        SelectObject(hDC, hPrevPen);
        DeleteObject(hPen);
    }
    else
    {
        /* Find a font with the right bold/italic/underlined attributes */
        i = 0;
        if (bits & COLOR_BOLD) i += 1;
        if (bits & COLOR_ITALIC) i += 2;
        if (bits & COLOR_UNDERLINED) i += 4;
        hFont = gwp->fonts[i];

        /* prepare DC & output text */
        SetTextColor(hDC, fgc);
        SetBkColor(hDC, bgc);
        SetBkMode(hDC, OPAQUE);
        SelectObject(hDC, hFont);
        options = ETO_OPAQUE | ETO_CLIPPED;
#ifdef FEATURE_IMAGE
        if (normalimage && (long)bgc == colorinfo[COLOR_FONT_NORMAL].bg)
        {
            gw_erase_rect(hDC, &rect, normalimage, gwp->scrolled);
            options = ETO_CLIPPED;
            SetBkMode(hDC, TRANSPARENT);
        }
        else if (idleimage && (long)bgc == colorinfo[COLOR_FONT_IDLE].bg)
        {
            gw_erase_rect(hDC, &rect, idleimage, gwp->scrolled);
            options = ETO_CLIPPED;
            SetBkMode(hDC, TRANSPARENT);
        }
#endif
        ExtTextOut(hDC, rect.left - ileft, rect.top, options, &rect,
                   (char *)text, len, gwp->font_size_array);
#ifdef FEATURE_IMAGE
        SetBkColor(hDC, bgc);
        SetBkMode(hDC, OPAQUE);
#endif
    }

    /* If COLOR_BOXED then draw a rectangle around the text */
    if (bits & (COLOR_BOXED | COLOR_LEFTBOX | COLOR_RIGHTBOX))
    {
        /* Select the foreground color */
        hPen = CreatePen(PS_SOLID, 0, fgc);
        hPrevPen = SelectObject(hDC, hPen);

        /* Draw the rectangle */
        if (bits & COLOR_BOXED)
        {
            MoveToEx(hDC, rect.left, rect.top, NULL);
            LineTo(hDC, rect.right, rect.top);
            MoveToEx(hDC, rect.left, rect.bottom - 1, NULL);
            LineTo(hDC, rect.right, rect.bottom - 1);
        }
        if (bits & COLOR_RIGHTBOX)
        {
            MoveToEx(hDC, rect.right - 1, rect.top, NULL);
            LineTo(hDC, rect.right - 1, rect.bottom);
        }
        if (bits & COLOR_LEFTBOX)
        {
            MoveToEx(hDC, rect.left, rect.top, NULL);
            LineTo(hDC, rect.left, rect.bottom);
        }

        /* Restore foreground color to its previous value, so we can delete
         * the local hPen object.
         */
        SelectObject(hDC, hPrevPen);
        DeleteObject(hPen);
    }

    /* release the window's device context */
    ReleaseDC(gwp->clientHWnd, hDC);

    /* update cursor position */
    gwp->curcol += len;
}
Example #5
0
void C3dMazeEffect::DrawMazeGaps(HDC hDC)
{
	int i, j;

	HPEN hPen = CreatePen(PS_SOLID, 1, MAZE_GRID_COLOR);
	HPEN hOldPen = (HPEN)SelectObject(hDC, hPen);

	const int xOffset = GetClientArea().right - m_pMaze->GetMazeSize()*MAZE_GRID_SIZE -1;
	const int yOffset = GetClientArea().top;

	// horizontal gaps
	for(i=0; i<m_pMaze->GetMazeSize()+1; i++)
	{
		for(j=0; j<m_pMaze->GetMazeSize(); j++)
		{
			if(m_pMaze->IsGap(j, i, TRUE))
			{
				MoveToEx(hDC, xOffset+j*MAZE_GRID_SIZE, yOffset+i*MAZE_GRID_SIZE, NULL);
				LineTo(hDC, xOffset+(j+1)*MAZE_GRID_SIZE, yOffset+i*MAZE_GRID_SIZE);
			}
		}
	}

	// vertical gaps
	for(i=0; i<m_pMaze->GetMazeSize(); i++)
	{
		for(j=0; j<m_pMaze->GetMazeSize()+1; j++)
		{
			if(m_pMaze->IsGap(j, i, FALSE))
			{
				MoveToEx(hDC, xOffset+j*MAZE_GRID_SIZE, yOffset+i*MAZE_GRID_SIZE, NULL);
				LineTo(hDC, xOffset+j*MAZE_GRID_SIZE, yOffset+(i+1)*MAZE_GRID_SIZE);
			}
		}
	}

	{	// original pos
		HBRUSH hBrush = CreateSolidBrush(MAZE_ORIGINAL_POS_COLOR);
		HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);
		SelectObject(hDC, GetStockObject(NULL_PEN));

		int x, y;
		m_pMaze->GetOriginalPos(x, y);

		Ellipse(hDC,
			xOffset + MAZE_GRID_SIZE/2 + x*MAZE_GRID_SIZE - MAZE_ORIGINAL_POS_SIZE/2,
			yOffset + MAZE_GRID_SIZE/2 + y*MAZE_GRID_SIZE - MAZE_ORIGINAL_POS_SIZE/2,
			xOffset + MAZE_GRID_SIZE/2 + x*MAZE_GRID_SIZE + MAZE_ORIGINAL_POS_SIZE/2,
			yOffset + MAZE_GRID_SIZE/2 + y*MAZE_GRID_SIZE + MAZE_ORIGINAL_POS_SIZE/2);

		SelectObject(hDC, hOldBrush);
		DeleteObject(hBrush);
	}

	{	// target pos
		HBRUSH hBrush = CreateSolidBrush(MAZE_TARGET_POS_COLOR);
		HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);
		SelectObject(hDC, GetStockObject(NULL_PEN));

		int x, y;
		m_pMaze->GetTargetPos(x, y);

		Ellipse(hDC,
			xOffset + MAZE_GRID_SIZE/2 + x*MAZE_GRID_SIZE - MAZE_TARGET_POS_SIZE/2,
			yOffset + MAZE_GRID_SIZE/2 + y*MAZE_GRID_SIZE - MAZE_TARGET_POS_SIZE/2,
			xOffset + MAZE_GRID_SIZE/2 + x*MAZE_GRID_SIZE + MAZE_TARGET_POS_SIZE/2,
			yOffset + MAZE_GRID_SIZE/2 + y*MAZE_GRID_SIZE + MAZE_TARGET_POS_SIZE/2);

		SelectObject(hDC, hOldBrush);
		DeleteObject(hBrush);
	}

	SelectObject(hDC, hOldPen);
	DeleteObject(hPen);
}
Example #6
0
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    PAINTSTRUCT ps;
    HDC hdc;
	RECT rect;
	SHORT vkShift=0;
	
	HFONT hfOld;
	long lfHeight;
	int iDevCap;
	LOGFONT logfont = { 0 };
    COLORREF oldTextColor;
	COPYDATASTRUCT* copyData;
	TCHAR* szTemp=new TCHAR(MAX_PATH);

	INITCOMMONCONTROLSEX InitCtrlEx;

	InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
	InitCtrlEx.dwICC  = ICC_PROGRESS_CLASS;
	InitCommonControlsEx(&InitCtrlEx);

	HPEN myPen, oldPen;

	switch (message) 
    {
        case WM_CREATE:
			//do font calculation
			hdc=GetWindowDC(hWnd);
			iDevCap=GetDeviceCaps(hdc, LOGPIXELSY);	//pixels per inch
			lfHeight = -((long)fontHeight * (long)iDevCap) / 72L;
			GetObject (GetStockObject (SYSTEM_FONT), sizeof (LOGFONT), (PTSTR) &logfont) ;
			//	HFONT hf = CreateFontIndirect(&logfont);
			logfont.lfHeight=lfHeight;
			hFont=CreateFontIndirect(&logfont);
			ReleaseDC(NULL,hdc);

			DEBUGMSG(1, (L"Create hWnd=%i\r\n", hWnd));
			if(iTimeOut>0)
				startThread(hWnd);

			if(bUseProgress){
				//progressBar
				hProgress = CreateWindowEx(0, PROGRESS_CLASS, NULL,
								WS_CHILD | WS_VISIBLE,
								xProgress, yProgress, xProgressWidth, yProgressHeight,
								hWnd, NULL, g_hInst, NULL);
				SendMessage(hProgress, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
				SendMessage(hProgress, PBM_SETPOS, iProgressVal, 0);
			}
			break;
		case WM_COPYDATA:
			copyData=(COPYDATASTRUCT*)lParam;
			myMsg _mymsg;
			if(copyData->dwData==1234)	//that's right
			{
				memcpy(&_mymsg, copyData->lpData, sizeof(myMsg));
			}
			if(_mymsg.iVal==0){		//text message
				if(wcslen(_mymsg.szText)>0)
					wcscpy(szMessageText, _mymsg.szText);
				GetClientRect(hWnd, &rect);
				InvalidateRect(hWnd, &rect, TRUE);
			}
			else if(_mymsg.iVal==1){		//progress message
				if(wcslen(_mymsg.szText)>0)
					wcscpy(szTemp, _mymsg.szText);
				iProgressVal=_wtoi(szTemp);
				SendMessage(hProgress, PBM_SETPOS, iProgressVal, 0);
			}
			break;			
        case WM_PAINT:
            hdc = BeginPaint(hWnd, &ps);
            
            // TODO: Add any drawing code here...
			GetClientRect(hWnd, &rect);
			//shrink text area if progressbar is there
			if(bUseProgress && hProgress!=NULL){
				rect.bottom-=yProgressHeight;
			}
			//draw rectangle
			myPen = CreatePen(PS_SOLID, 1, RGB(0,0,0));
			oldPen = (HPEN)SelectObject(hdc,myPen);
			SelectObject(hdc, hBackcolor);
			Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
			//shrinkRect(&rect, 1);
			//Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
			//a drop shadow
			rect.right-=1;rect.bottom-=1;
			Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
			rect.right-=1;rect.bottom-=1;
			Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
			SelectObject(hdc, oldPen);

			SetBkMode(hdc, TRANSPARENT);
			oldTextColor = SetTextColor(hdc, RGB(fontColorRed, fontColorGreen, fontColorBlue));
			hfOld=(HFONT)SelectObject(hdc, hFont);
            DrawText(hdc, 
				szMessageText,	//text to draw
				-1,				//length of text
				&rect, 
				dwTextalign | DT_END_ELLIPSIS | DT_EXTERNALLEADING | DT_VCENTER // | DT_SINGLELINE		//text formatting
				);

            EndPaint(hWnd, &ps);
			SelectObject(hdc, hfOld);
			SetTextColor(hdc, oldTextColor);

			//if(hProgress!=NULL)

			DeleteObject(hFont);
            break;
		case WM_LBUTTONDBLCLK:
			vkShift=GetKeyState(VK_CAPITAL);
			if( (vkShift & 0x80) == 0x80 || (vkShift & 0x01) == 0x01 ){
				if(MessageBox(hWnd, L"Exit?", L"showWin", MB_OKCANCEL)==IDOK)
					DestroyWindow(hWnd);
			}
			break;
		case WM_QUIT:
			DEBUGMSG(1, (L"WM_QUIT \r\n"));
			break;
        case WM_DESTROY:
			stopThread();
            PostQuitMessage(0);
            break;


        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
    }
	delete szTemp;
    return 0;
}
Example #7
0
File: main.c Project: ozgend/hive
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
	{
		HDC hdc;
		PAINTSTRUCT ps;
		RECT rc;
		HBRUSH hBrush, hBrushOld;
		HPEN hPen, hPenOld;
		LOGBRUSH lgBrush;
		int index;
		static BioAPI_UUID_PTR uuid;
		BioAPI_RETURN bioReturn;
		TCHAR szUserName[100];
		BioAPI_VERSION Version;

		BioAPI_BIR_HANDLE EnrolledTemplate, CapturedTemplate, ProcessedBir;

		BioAPI_INPUT_BIR birEnroll, birCapture, InputBirProcessed;
		BioAPI_BIR_HEADER birHeader;
		BioAPI_FAR MaxFAR, AchievedFAR;

		BioAPI_BOOL bResponse;
		BioAPI_BOOL bPrecedence = BioAPI_TRUE;

		static BioAPI_BSP_SCHEMA * CurrSchema;

		switch (iMsg)
			{
			case WM_PAINT :
				hdc = BeginPaint(hwnd, &ps);
				GetClientRect(hwnd, &rc);
				lgBrush.lbStyle = BS_SOLID;
				lgBrush.lbColor = GetSysColor(COLOR_3DFACE);
				hBrush = CreateBrushIndirect(&lgBrush);
				hPen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DFACE));
				hPenOld = SelectObject(hdc, hPen);
				hBrushOld = SelectObject(hdc, hBrush);
				Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom);
				SelectObject(hdc, hBrushOld);
				SelectObject(hdc, hPenOld);
				DeleteObject(hBrush);
				DeleteObject(hPen);
				EndPaint(hwnd, &ps);
				return 0;

			case WM_COMMAND :
				switch (HIWORD (wParam))
					{
					case CBN_SELCHANGE :
						ReleaseBSP(&uuid);

						// Retrieve the index of the item selected
						index = SendMessage(hEnumTech, CB_GETCURSEL, 0, 0);
						// Retrieve a pointer to the uuid for the module
						CurrSchema = (BioAPI_BSP_SCHEMA *)SendMessage(hEnumTech, CB_GETITEMDATA, index, 0);
						uuid = (BioAPI_UUID *)malloc(sizeof(BioAPI_UUID));
						if(uuid == NULL)
						{
							MessageBox(hwnd, TEXT("Unable to allocate memory to load the module identifier"),
										TEXT("BioAPI Sample"), MB_OK);
							return 0;
						}
						BioAPI_CopyUuid(uuid, CurrSchema->ModuleId);
						bioReturn = BioAPI_ModuleLoad(uuid, 0, NULL/*(BioAPI_ModuleEventHandler)BiometricEventHandler*/, 0);

						if(BioAPI_OK != bioReturn)
							{
								PrintErrorCode(bioReturn);
								free(uuid);
								uuid = NULL;
								return 0;
							}
//						wsprintf(szCurrHandle, TEXT("Current Handle: 0x%X"), hBtCurrent);
//						SetWindowText(hCurrHbt, szCurrHandle);

						Version.Major = BioAPI_MAJOR;
						Version.Minor = BioAPI_MINOR;
						bioReturn = BioAPI_ModuleAttach(uuid, &Version, &BioAPIWinMemoryFuncs,
										0,
										0,0,0,
										NULL,
										0,
										NULL,
										&gModuleHandle);
						if(BioAPI_OK != bioReturn)
							{
								PrintErrorCode(bioReturn);
								BioAPI_ModuleUnload (uuid, NULL, 0);
								free(uuid);
								uuid = NULL;
								return 0;
							}

						break;

					case BN_CLICKED:
						switch (LOWORD (wParam))
							{
								case IDOK :
									ReleaseBSP(&uuid);
									EndDialog(hwnd, 0);
									PostQuitMessage(0);
									break;
								case IDC_ENROLL :
									if(GetWindowText(hUserId, szUserName, 100)==0)
										MessageBox(hwnd, TEXT("Please specify a user id"), TEXT("Bad User Id"), MB_OK);
									else
										{
											bioReturn = BioAPI_Enroll(gModuleHandle,
															BioAPI_PURPOSE_ENROLL_FOR_VERIFICATION_ONLY,
															NULL,
															&EnrolledTemplate,
															NULL,
															-1,
															NULL);

											if(bioReturn != BioAPI_OK)
												{
													PrintErrorCode(bioReturn);
													return 0;
												}

											OutputToFile(szUserName, EnrolledTemplate);
										}
									break;
								case IDC_VERIFY :
									if(GetWindowText(hUserId, szUserName, 100)==0)
										MessageBox(hwnd, TEXT("Please specify a user id"), TEXT("Bad User Id"), MB_OK);
									else
										{
											if(InputFromFile(szUserName, &birEnroll) != BioAPI_OK)
												{
													MessageBox(hwnd, TEXT("User not enrolled"), TEXT("Bad User Id"), MB_OK);
													return 0;
												}
											// See if the BSP supports BioAPI_VerifyMatch by checking
											// the operations mask
											if(CurrSchema->Operations & BioAPI_VERIFYMATCH)
												{
													if((bioReturn = BioAPI_Capture(gModuleHandle,
																		BioAPI_PURPOSE_VERIFY,
																		&CapturedTemplate,
																		-1,
																		NULL)) != BioAPI_OK)
														{
															PrintErrorCode(bioReturn);
															GlobalFree(birEnroll.InputBIR.BIR);
															return 0;
														}
													if((bioReturn = BioAPI_GetHeaderFromHandle(gModuleHandle,
																		CapturedTemplate,
																		&birHeader)) != BioAPI_OK)
														{
															PrintErrorCode(bioReturn);
															GlobalFree(birEnroll.InputBIR.BIR);
															return 0;
														}
													if(birHeader.Type == BioAPI_BIR_DATA_TYPE_INTERMEDIATE)
														{
															birCapture.Form = BioAPI_BIR_HANDLE_INPUT;
															birCapture.InputBIR.BIRinBSP = &CapturedTemplate;
															if((bioReturn = BioAPI_Process(gModuleHandle,
																				&birCapture,
																				&ProcessedBir)) != BioAPI_OK)
																{
																	PrintErrorCode(bioReturn);
																	GlobalFree(birEnroll.InputBIR.BIR);
																	return 0;
																}
															MaxFAR = 1;
															InputBirProcessed.Form = BioAPI_BIR_HANDLE_INPUT;
															InputBirProcessed.InputBIR.BIRinBSP = &ProcessedBir;
														}
													else
														{
															MaxFAR = 1;
															InputBirProcessed.Form = BioAPI_BIR_HANDLE_INPUT;
															InputBirProcessed.InputBIR.BIRinBSP = &CapturedTemplate;
														}
													bioReturn = BioAPI_VerifyMatch(gModuleHandle,
																	&MaxFAR,
																	NULL,
																	&bPrecedence,
																	&InputBirProcessed,
																	&birEnroll,
																	NULL,
																	&bResponse,
																	&AchievedFAR,
																	NULL,
																	NULL);
												}
											else		// We simply call BioAPI_Verify
												{
													MaxFAR = 1;
													bioReturn = BioAPI_Verify(gModuleHandle,
																				&MaxFAR,
																				NULL,
																				&bPrecedence,
																				&birEnroll,
																				NULL,
																				&bResponse,
																				&AchievedFAR,
																				NULL,
																				NULL,
																				-1,
																				NULL);
												}
											GlobalFree(birEnroll.InputBIR.BIR);

											if(bioReturn != BioAPI_OK)
												{
													PrintErrorCode(bioReturn);
													return 0;
												}
											if(bResponse == TRUE)
												MessageBox(hwnd, TEXT("Match"), TEXT("BioAPI"), MB_OK);
											else MessageBox(hwnd, TEXT("No Match"), TEXT("BioAPI"), MB_OK);
										}
									break;
							}
						break;
					}
				return 0 ;
			case WM_CLOSE :
				ReleaseBSP(&uuid);
				EndDialog(hwnd, 0);
				PostQuitMessage(0);
				return 0;
			case WM_DESTROY :
				ReleaseBSP(&uuid);
				EndDialog(hwnd, 0);
				PostQuitMessage(0);
				return 0 ;
			}
		return DefWindowProc (hwnd, iMsg, wParam, lParam) ;
	}
Example #8
0
/**
 * Below CheckMessageBoxProc adds everyones favorite "don't show again" checkbox to the dialog
 * much of the layout code (especially for XP and older windows versions) is copied with changes
 * from a GPL'ed project emabox at SourceForge.
 **/
LRESULT CALLBACK CheckMessageBoxProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
		case WM_COMMAND:
		{
			if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == 2025)
			{
				const LRESULT res = SendMessage((HWND)lParam, BM_GETSTATE, 0, 0);
				bool bCheckedAfter = ((res & BST_CHECKED) == 0);
				
				// Update usedata
				ExMessageBox::SetUserData((void*)(bCheckedAfter ? BST_CHECKED : BST_UNCHECKED)); //-V204
				
				SendMessage((HWND)lParam, BM_SETCHECK, bCheckedAfter ? BST_CHECKED : BST_UNCHECKED, 0);
			}
		}
		break;
		case WM_ERASEBKGND:
		{
			// Vista+ has grey strip
#ifdef FLYLINKDC_SUPPORT_WIN_XP
			if (CompatibilityManager::isOsVistaPlus())
#endif
			{
				RECT rc = {0};
				HDC dc = (HDC)wParam;
				
				// Fill the entire dialog
				GetClientRect(hWnd, &rc);
				FillRect(dc, &rc, GetSysColorBrush(COLOR_WINDOW));
				
				// Calculate strip height
				RECT rcButton = {0};
				GetWindowRect(FindWindowEx(hWnd, NULL, L"BUTTON", NULL), &rcButton);
				int stripHeight = (rcButton.bottom - rcButton.top) + 24;
				
				// Fill the strip
				rc.top += (rc.bottom - rc.top) - stripHeight;
				FillRect(dc, &rc, GetSysColorBrush(COLOR_3DFACE));
				
				// Make a line
				HGDIOBJ oldPen = SelectObject(dc, CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DLIGHT)));
				MoveToEx(dc, rc.left - 1, rc.top, (LPPOINT)NULL);
				LineTo(dc, rc.right, rc.top);
				DeleteObject(SelectObject(dc, oldPen));
				return S_OK;
			}
		}
		break;
		case WM_CTLCOLORSTATIC:
		{
			// Vista+ has grey strip
			if (
#ifdef FLYLINKDC_SUPPORT_WIN_XP
			    CompatibilityManager::isOsVistaPlus() &&
#endif
			    ((HWND)lParam == GetDlgItem(hWnd, 2025)))
			{
				HDC hdc = (HDC)wParam;
				SetBkMode(hdc, TRANSPARENT);
				return (LRESULT)GetSysColorBrush(COLOR_3DFACE);
			}
		}
		break;
		case WM_INITDIALOG:
		{
			RECT rc = {0};
			HWND current = NULL;
			int iWindowWidthBefore;
			int iWindowHeightBefore;
			int iClientHeightBefore;
			int iClientWidthBefore;
			
			pair<LPCTSTR, UINT> checkdata = (*(pair<LPCTSTR, UINT>*)ExMessageBox::GetUserData());
			
			GetClientRect(hWnd, &rc);
			iClientHeightBefore = rc.bottom - rc.top;
			iClientWidthBefore = rc.right - rc.left;
			
			GetWindowRect(hWnd, &rc);
			iWindowWidthBefore = rc.right - rc.left;
			iWindowHeightBefore = rc.bottom - rc.top;
			
			// Create checkbox (resized and moved later)
			HWND check = CreateWindow(L"BUTTON", checkdata.first, WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_VCENTER | BS_CHECKBOX,
			                          CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
			                          hWnd, (HMENU)2025, GetModuleHandle(NULL), NULL
			                         );
			                         
			// Assume checked by default
			SendMessage(check, BM_SETCHECK, checkdata.second, 0); //-V106
			ExMessageBox::SetUserData((void*)checkdata.second); //-V204
			
			// Apply default font
			const int cyMenuSize = GetSystemMetrics(SM_CYMENUSIZE);
			const int cxMenuSize = GetSystemMetrics(SM_CXMENUSIZE);
			const HFONT hNewFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
			HFONT hOldFont;
			SIZE size;
			
			SendMessage(check, WM_SETFONT, (WPARAM)hNewFont, (LPARAM)TRUE);
			
			// Get the size of the checkbox
			HDC hdc = GetDC(check);
			hOldFont = (HFONT)SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
			GetTextExtentPoint32(hdc, checkdata.first, wcslen(checkdata.first), &size); //-V107
			SelectObject(hdc, hOldFont);
			int l_res = ReleaseDC(check, hdc);
			dcassert(l_res);
			
			// Checkbox dimensions
			int iCheckboxWidth = cxMenuSize + size.cx + 1;
			int iCheckboxHeight = (cyMenuSize > size.cy) ? cyMenuSize : size.cy;
			
			// Vista+ has a different kind of layout altogether
#ifdef FLYLINKDC_SUPPORT_WIN_XP
			if (CompatibilityManager::isOsVistaPlus())
#endif
			{
				// Align checkbox with buttons (aproximately)
				int iCheckboxTop = int(iClientHeightBefore - (iCheckboxHeight * 1.70));
				MoveWindow(check, 5, iCheckboxTop, iCheckboxWidth, iCheckboxHeight, FALSE);
				
				// Resize and re-center dialog
				int iWindowWidthAfter = iWindowWidthBefore + iCheckboxWidth;
				int iWindowLeftAfter = rc.left + (iWindowWidthBefore - iWindowWidthAfter) / 2;
				MoveWindow(hWnd, iWindowLeftAfter, rc.top, iWindowWidthAfter, iWindowHeightBefore, TRUE);
				
				// Go through the buttons and move them
				while ((current = FindWindowEx(hWnd, current, L"BUTTON", NULL)) != NULL)
				{
					if (current == check) continue;
					
					RECT rc;
					GetWindowRect(current, &rc);
					ScreenToClient(hWnd, &rc);
					MoveWindow(current, rc.left + iCheckboxWidth, rc.top, rc.right - rc.left, rc.bottom - rc.top, FALSE);
				}
			}
#ifdef FLYLINKDC_SUPPORT_WIN_XP
			else
			{
				RECT rt = {0}, rb = {0};
				
				// Let's find us the label
				while ((current = FindWindowEx(hWnd, current, L"STATIC", NULL)) != NULL)
				{
					if (GetWindowTextLength(current) > 0)
					{
						GetWindowRect(current, &rt);
						ScreenToClient(hWnd, &rt);
						//current = NULL; [-] IRainman.
						break;
					}
				}
				
				// For correcting width, here just to make lines shorter
				int iWidthAdjustment = (rt.left + iCheckboxWidth) - iWindowWidthBefore;
				
				// Go through the buttons and move them
				current = NULL;
				while ((current = FindWindowEx(hWnd, current, L"BUTTON", NULL)) != NULL)
				{
					if (current == check) continue;
					
					GetWindowRect(current, &rb);
					ScreenToClient(hWnd, &rb);
					MoveWindow(current, rb.left + (iWidthAdjustment > 0 ? (iWidthAdjustment + 15) / 2 : 0), rb.top + iCheckboxHeight, rb.right - rb.left, rb.bottom - rb.top, FALSE);
				}
				
				// Move the checkbox
				int iCheckboxTop = rt.top + (rt.bottom - rt.top) + ((rb.top - rt.bottom) / 2);
				MoveWindow(check, rt.left, iCheckboxTop, iCheckboxWidth, iCheckboxHeight, FALSE);
				
				// Resize and re-center dialog
				int iWindowHeightAfter = iWindowHeightBefore + iCheckboxHeight;
				int iWindowTopAfter = rc.top + (iWindowHeightBefore - iWindowHeightAfter) / 2;
				int iWindowWidthAfter = (iWidthAdjustment > 0) ? iWindowWidthBefore + iWidthAdjustment + 15 : iWindowWidthBefore;
				int iWindowLeftAfter = rc.left + (iWindowWidthBefore - iWindowWidthAfter) / 2;
				MoveWindow(hWnd, iWindowLeftAfter, iWindowTopAfter, iWindowWidthAfter, iWindowHeightAfter, TRUE);
			}
#endif // FLYLINKDC_SUPPORT_WIN_XP
		}
		break;
	}
	
	return ::CallWindowProc(ExMessageBox::GetMessageBoxProc(), hWnd, uMsg, wParam, lParam);
	// Кончается стек... бесконечная рекурсия
	// Unhandled exception at 0x77d3c003 in 2012-04-27_18-43-09_NDUW2D6QMG4YW36BN5UIAXMGUWMOTLLXKMILQ6Q_277CD9CA_crash-stack-r502-beta22-build-9854.dmp: 0xC00000FD: Stack overflow.
	// 2012-04-23_22-28-18_DSYQLU4LP7CX6GDDAJ2UFRPXE3X3PHVA4OOCMGQ_415AC914_crash-stack-r501-build-9812.dmp
	// 2012-04-23_22-28-18_3TDJE6PDPJVMCHG4IMQ4J6THX5JGGDU6GTKOKXI_2F62C66F_crash-stack-r501-build-9812.dmp
	// 2012-04-27_18-43-09_NDUW2D6QMG4YW36BN5UIAXMGUWMOTLLXKMILQ6Q_277CD9CA_crash-stack-r502-beta22-build-9854.dmp
	// 2012-04-29_13-38-26_ZJYWDXZXYANBHCEY32VASIUYEJQ2EB5XMWA4DZA_26E2DB15_crash-stack-r501-build-9869.dmp
	// 2012-04-29_06-52-32_2ZWT4UCCVZF6NY5WNYA46H7GEH5ZSFOWC7J7D2A_9CAEF098_crash-stack-r502-beta23-build-9860.dmp
	// 2012-04-29_06-52-32_YBYPEJ554SEGC5Y6RAZS5XBVQVRFKTG5562647I_8C6E282F_crash-stack-r502-beta23-build-9860.dmp
	// 2012-04-29_06-52-32_FLVDGJORDX6VOATQ6Q4FWBFOPGT26F627IOPETA_0E91B420_crash-stack-r502-beta23-build-9860.dmp
	// 2012-04-29_06-52-32_2X3ZUVYNFGXE54Z4WY3HOTK6S2IYWLAPCFVSOZQ_B5C12568_crash-stack-r502-beta23-build-9860.dmp
	// 2012-05-03_22-00-59_RMCI35S5BUYUMZRKV3RRX6JH6TMPFNA7KOW5CUI_5339ECA4_crash-stack-r502-beta24-build-9900.dmp
	// 2012-05-03_22-00-59_LHR2RITWPBE3LLJJBQHIH64Z2F3WX6M77XZ46RQ_5AF21F88_crash-stack-r502-beta24-build-9900.dmp
}
Example #9
0
LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{

	switch (message)
	{
	case WM_TIMER:
		if (animationDone) break;
		nameListPos += GFX::TextSpeed;
		if (nameListPos > (kidList.nRecords-1)) {
			nameListPos = (float) (kidList.nRecords - 1);
			KillTimer(hWnd, timerID);
			timerID = NULL;
			animationDone = true;
			showCreditBox = true;
		}
		InvalidateRect(hWnd, NULL, false);
		break;
	case WM_CREATE:
		break;
	case WM_PAINT:
	{
		PAINTSTRUCT ps;
		HDC hdc = BeginPaint(hWnd, &ps);

		// Create an off-screen DC for double-buffering
		HDC hdcM = CreateCompatibleDC(hdc);
		RECT cR;  GetClientRect(hWnd, &cR);
		HBITMAP hbmMem = CreateCompatibleBitmap(hdc, cR.right, cR.bottom);
		HGDIOBJ hOld = SelectObject(hdcM, hbmMem);

		HBRUSH oldB = (HBRUSH) SelectObject(hdcM, CreateSolidBrush(GFX::backgr));
		HPEN oldP = (HPEN) SelectObject(hdcM, CreatePen(PS_SOLID, 1, GFX::backgr));
		
		Rectangle(hdcM, 0, 0, cR.right+1, cR.bottom+1);
		SetMapMode(hdcM, MM_TEXT);
		HFONT font = CreateFont((UINT)(cR.bottom * GFX::TextHeight), 0, 0, 0, GFX::TextWeight,
			GFX::isItalic, false, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
			CLEARTYPE_QUALITY, DEFAULT_PITCH | GFX::TextFamily, NULL);
		HFONT oldF = (HFONT)SelectObject(hdcM, font);
		SetTextColor(hdcM, GFX::textcolor);
		SetBkColor(hdcM, GFX::backgr);
		// draw two names, the floor of nameListPos and the ceil of nameListPos
		UINT n1 = (int)nameListPos;  UINT n2 = n1 + 1;
		float fp = nameListPos - n1;
		if ( (n1 >= 0) && (n1 < kidList.nRecords)) {
			RECT cR1 = cR;
			float off = fp * cR.bottom;
			cR1.top -= (int) off; cR1.bottom -= (int) off;
			DrawText(hdcM, kidList.pRecords[n1]->name, wcslen(kidList.pRecords[n1]->name)
				, &cR1, DT_CENTER | DT_VCENTER);
		}
		if ((n2 >= 0) && (n2 < kidList.nRecords)) {
			RECT cR2 = cR;
			float off = ((fp-1.0f) * cR.bottom);
			cR2.top -= (int) off; cR2.bottom -= (int) off;
			DrawText(hdcM, kidList.pRecords[n2]->name, wcslen(kidList.pRecords[n2]->name)
				, &cR2, DT_CENTER | DT_VCENTER);
		}


		DeleteObject(SelectObject(hdcM, oldB));
		DeleteObject(SelectObject(hdcM, oldP));
		DeleteObject(SelectObject(hdcM, oldF));

		// Transfer the off-screen DC to the screen
		BitBlt(hdc, 0, 0, cR.right, cR.bottom, hdcM, 0, 0, SRCCOPY);

		// Free-up the off-screen DC
		SelectObject(hdcM, hOld);
		DeleteObject(hbmMem);
		DeleteDC(hdcM);

		EndPaint(hWnd, &ps);
		if (showCreditBox) {
			showCreditBox = false;
			UINT msg = MessageBox(hWnd, L"Did student answer?", L"Credit"
				, MB_YESNOCANCEL | MB_ICONQUESTION | MB_SYSTEMMODAL);
			UINT n = kidList.nRecords - 1;
			switch (msg) {
			case IDYES:
				kidList.pRecords[n]->credits++;
			case IDNO:
				kidList.pRecords[n]->turns++;
				break;
			}
			PostQuitMessage(0);
		}
	}
	break;
	case WM_ERASEBKGND:
		return true;
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
Example #10
0
BOOL CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{

	switch (message)
	{
		case WM_INITDIALOG:
		{
			int nColor;
			for (nColor = 0 ; nColor < int(sizeof(colourItems)/sizeof(DWORD)) ; nColor++)
			{
				::SendDlgItemMessage(_hSelf, IDC_COLOUR_LIST, LB_ADDSTRING, nColor, (LPARAM) "");
				::SendDlgItemMessage(_hSelf, IDC_COLOUR_LIST, LB_SETITEMDATA , nColor, (LPARAM) colourItems[nColor]);
				//if (g_bgColor == colourItems[nColor])
					//::SendDlgItemMessage(_hSelf, IDC_COLOUR_LIST, LB_SETCURSEL, nColor, 0);
			}
			//::SetCapture(_hSelf);
			return TRUE;
		}

		case WM_CTLCOLORLISTBOX:
			return (LRESULT) CreateSolidBrush(GetSysColor(COLOR_3DFACE));

		case WM_DRAWITEM:
		{
			HDC hdc;
			COLORREF	cr;
			HBRUSH		hbrush;

			DRAWITEMSTRUCT *pdis = (DRAWITEMSTRUCT *)lParam;
			hdc = pdis->hDC;
			RECT rc = pdis->rcItem;

			// Transparent.
			SetBkMode(hdc,TRANSPARENT);

			// NULL object
			if (pdis->itemID == UINT(-1)) return 0;

			switch (pdis->itemAction)
			{
				case ODA_DRAWENTIRE:
					switch (pdis->CtlID)
					{
						case IDC_COLOUR_LIST:
							rc = pdis->rcItem;
							cr = (COLORREF) pdis->itemData;
							InflateRect(&rc, -3, -3);
							hbrush = CreateSolidBrush((COLORREF)cr);
							FillRect(hdc, &rc, hbrush);
							DeleteObject(hbrush);
							FrameRect(hdc, &rc, (HBRUSH) GetStockObject(GRAY_BRUSH));
							break;

						NO_DEFAULT_CASE;
					}
					// *** FALL THROUGH ***
					//lint -fallthrough
				case ODA_SELECT:
					rc = pdis->rcItem;
					if (pdis->itemState & ODS_SELECTED)
					{
						rc.bottom --;
						rc.right --;
						// Draw the lighted side.
						HPEN hpen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_BTNSHADOW));
						HPEN holdPen = (HPEN)SelectObject(hdc, hpen);
						MoveToEx(hdc, rc.left, rc.bottom, NULL);
						LineTo(hdc, rc.left, rc.top);
						LineTo(hdc, rc.right, rc.top);
						SelectObject(hdc, holdPen);
						DeleteObject(hpen);
						// Draw the darkened side.
						hpen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_BTNHIGHLIGHT));
						holdPen = (HPEN)SelectObject(hdc, hpen);
						LineTo(hdc, rc.right, rc.bottom);
						LineTo(hdc, rc.left, rc.bottom);
						SelectObject(hdc, holdPen);
						DeleteObject(hpen);
					}
					else
					{
						hbrush = CreateSolidBrush(GetSysColor(COLOR_3DFACE));
						FrameRect(hdc, &rc, hbrush);
						DeleteObject(hbrush);
					}
					break;
				case ODA_FOCUS:
					rc = pdis->rcItem;
					InflateRect(&rc, -2, -2);
					DrawFocusRect(hdc, &rc);
					break;
				default:
					break;
			}
			return TRUE;
		}

		case WM_COMMAND:
			switch (LOWORD(wParam))
            {
                case IDOK :
			    {
					isColourChooserLaunched = true;
					CHOOSECOLOR cc;                 // common dialog box structure
					static COLORREF acrCustClr[16] = {
						RGB(0xFF,0xFF,0xFF),RGB(0xFF,0xFF,0xFF),RGB(0xFF,0xFF,0xFF),RGB(0xFF,0xFF,0xFF),\
						RGB(0xFF,0xFF,0xFF),RGB(0xFF,0xFF,0xFF),RGB(0xFF,0xFF,0xFF),RGB(0xFF,0xFF,0xFF),\
						RGB(0xFF,0xFF,0xFF),RGB(0xFF,0xFF,0xFF),RGB(0xFF,0xFF,0xFF),RGB(0xFF,0xFF,0xFF),\
						RGB(0xFF,0xFF,0xFF),RGB(0xFF,0xFF,0xFF),RGB(0xFF,0xFF,0xFF),RGB(0xFF,0xFF,0xFF),\
					}; // array of custom colors

					// Initialize CHOOSECOLOR
					::ZeroMemory(&cc, sizeof(cc));
					cc.lStructSize = sizeof(cc);
					cc.hwndOwner = _hParent;

					cc.lpCustColors = (LPDWORD) acrCustClr;
					cc.rgbResult = _colour;
					cc.Flags = CC_FULLOPEN | CC_RGBINIT;

					display(false);

					if (ChooseColor(&cc)==TRUE)
					{
						::SendMessage(_hParent, WM_PICKUP_COLOR, cc.rgbResult, 0);
					}
					else
					{
						::SendMessage(_hParent, WM_PICKUP_CANCEL, 0, 0);
					}

				    return TRUE;
			    }

                case IDC_COLOUR_LIST :
                {
			        if (HIWORD(wParam) == LBN_SELCHANGE)
		            {
                        int i = ::SendMessage((HWND)lParam, LB_GETCURSEL, 0L, 0L);
                        _colour = ::SendMessage((HWND)lParam, LB_GETITEMDATA, i, 0L);

                        ::SendMessage(_hParent, WM_PICKUP_COLOR, _colour, 0);
					    return TRUE;
		            }
		            return FALSE;
                }

                default :
                    return FALSE;
            }

		case WM_ACTIVATE :
        {
			if (LOWORD(wParam) == WA_INACTIVE)
				if (!isColourChooserLaunched)
					::SendMessage(_hParent, WM_PICKUP_CANCEL, 0, 0);
			return TRUE;
		}

		default:
		break;
	}
	return FALSE;
}
Example #11
0
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     // код уведомления
	UINT idChild = LOWORD(wParam);     // идентификатор дочернего окна
	HWND hwndChild = (HWND)lParam;     // дескриптор дочернего 
	PAINTSTRUCT ps;
	
	switch (message){
	case WM_CREATE:{
		PWINDOWINFO pwi = malloc(sizeof(WINDOWINFO));
		if (!pwi){
			CloseWindowMy(hwnd);
			break;
		}
		GetWindowInfo(hwnd, pwi);
		int w = pwi->rcClient.right - pwi->rcClient.left;
		int h = pwi->rcClient.bottom - pwi->rcClient.top;
		free(pwi);
		HWND hwndExit = CreateWindowA("button", "закрыть", WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE, 0, h - 30, w / 2, 30, hwnd, (HMENU)ID_BUTTON_EXIT, NULL, NULL);
		HWND hwndTurn = CreateWindowA("button", "свернуть", WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE, w / 2, h - 30, w / 2, 30, hwnd, (HMENU)ID_BUTTON_TURN, NULL, NULL);
		HWND hwndAutoRun = CreateWindowA("button", NULL, WS_CHILD | BS_AUTOCHECKBOX | WS_VISIBLE, 300, 131, 15, 15, hwnd, (HMENU)ID_BUTTON_AUTORUN, NULL, NULL);
		HWND hwndHotKey = CreateWindowA("Edit", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_READONLY, 230, 10, 50, 20, hwnd, (HMENU)ID_EDIT_HOTKEY, NULL, NULL);
		glbOldEditProc = SetWindowLongW(hwndHotKey, GWL_WNDPROC, (LONG)newEditProc); //замена процесса обработки сообщений едита 
		ShowWindow(hwndHotKey, SW_NORMAL);
		ShowWindow(hwndExit, SW_NORMAL);
		ShowWindow(hwndAutoRun, SW_NORMAL);
		ShowWindow(hwndTurn, SW_NORMAL);
		UINT ChekAutoRunResult = ChekAutoRun(); //проверяем, есть ли автозагрузка 
		if (ChekAutoRunResult == MYERROR){

			CloseWindowMy(hwnd);
			break;

		}
		else if (ChekAutoRunResult == SUCCESS)
			SendMessageA(hwndAutoRun, BM_SETCHECK, 1, 0); //устанавливаем галочку автозагрузки, если она есть
		CreatIcon(hwnd);
		INT hotKeyCode = SetHotKeyToEdit(hwndHotKey);
		if (hotKeyCode == MYERROR){//установка горячей клавиши
			CloseWindowMy(hwnd);
			break;
		}
		pInitHotKeyDll(hotKeyCode,hwndHotKey); //в длл ее
		break;
	}

	case WM_ICON:{
		switch (lParam)  {
		case WM_LBUTTONDBLCLK:{
			ShowWindow(hwnd, SW_NORMAL); // работа с иконкой

			break;
		}
		default:
			break;
		}
		break;
	}
	case WM_COMMAND:{
		if (idChild == ID_BUTTON_EXIT){
			CloseWindowMy(hwnd);  
		}
		if (idChild == ID_BUTTON_TURN){

			ShowWindow(hwnd, SW_HIDE);

		}


		if (idChild == ID_BUTTON_AUTORUN){ // если захотели автозагрузку
			LRESULT result = SendMessageA(hwndChild, BM_GETCHECK, 0, 0);
			if (result == BST_CHECKED){ //если галочка ставится
				char *szFileName = malloc(MAX_LENGTH);
				if (!szFileName){
					CloseWindowMy(hwnd);







					break;
				}
				memset(szFileName, 0, MAX_LENGTH);


				GetModuleFileNameA(NULL, szFileName, MAX_PATH);

				if (SetAutoRunToReg((LPBYTE)szFileName, strlen(szFileName)) == MYERROR){//добавляем наше приложение в автозагрузку
					glbPaintError = MYERROR;
					SendMessageA(hwndChild, BM_SETCHECK, 0, 0); // если вдруг что-то пошло не так, выводим ошибку
					InvalidateRect(hwnd, 0, 0);
					SendMessageA(hwnd, WM_PAINT, 0,0);



				}
				else{
					glbPaintError = SUCCESS;
					InvalidateRect(hwnd, 0,0);
					SendMessageA(hwnd, WM_PAINT, 0, 0);
				}
			}
			else {
				if (SetAutoRunToReg(NULL, 0) == MYERROR){//удаляем наше приложение из автозагрузки dsfdsSDFDSFsdfdasdsadASDSADfdfdsfSDFDSS
					glbPaintError = MYERROR;
					SendMessageA(hwndChild, BM_SETCHECK, 1, 0);
					InvalidateRect(hwnd, 0, 0);
					SendMessageA(hwnd, WM_PAINT, 0,0);

				}
				else{
					glbPaintError = SUCCESS;
					InvalidateRect(hwnd, 0, 0);
					SendMessageA(hwnd, WM_PAINT, 0, 0);


				}

			}
		}
		break;
	}




	case WM_PAINT:{


		HDC hdc = BeginPaint(hwnd, &ps);
		HBRUSH hBrush = CreateSolidBrush(RGB(0xff, 0xff, 0xff));
		HPEN hPen = CreatePen(PS_SOLID, 2, RGB(0xff, 0xff, 0xff));
		SelectObject(hdc, hPen);
		SelectObject(hdc, hBrush);        


		 
		WINDOWINFO wi;
		GetWindowInfo(hwnd, &wi);
		int w = wi.rcClient.right - wi.rcClient.left;
		int h = wi.rcClient.bottom - wi.rcClient.top;

		Rectangle(hdc, 0, 0, w, h);
		TextOutA(hdc, 10, 10, "Клавиша для переключения:", 25);
		TextOutA(hdc, 10, 30, "Для смены клавиши, нажмите мышкой на рамку,", 42);
		TextOutA(hdc, 10, 50, "Затем нажмите нужную клавишу из списка:", 39);
		TextOutA(hdc, 10, 70, "1. Shift", 8);
		TextOutA(hdc, 10, 85, "2. Pause", 8);
		TextOutA(hdc, 10, 100, "3. ctrl", 7);
		TextOutA(hdc, 10, 130, "Запуск Свичера при загрузке Windows:", 36);


		if (glbPaintError == MYERROR){

			TextOutA(hdc, 10, 115, "Не удается изменить состояние автозагрузки.", 43);

		}
		EndPaint(hwnd, &ps);
	}

	default:
		return DefWindowProc(hwnd, message, wParam, lParam);
	}
	return 0;
}
static LRESULT myWindowProc(HWND hWnd,	UINT Msg, WPARAM wParam, LPARAM lParam)
{
	HDC				dc;
	PAINTSTRUCT		ps;
	GDisplay *		g;
	winPriv *		priv;
	#if GINPUT_NEED_TOGGLE
		HBRUSH		hbrOn, hbrOff;
		HPEN		pen;
		RECT		rect;
		HGDIOBJ		old;
		POINT 		p;
		coord_t		pos;
		uint8_t		bit;
	#endif

	switch (Msg) {
	case WM_CREATE:
		// Get our GDisplay structure and attach it to the window
		g = (GDisplay *)((LPCREATESTRUCT)lParam)->lpCreateParams;
		priv = (winPriv *)g->priv;
		SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)g);

		// Fill in the private area
		priv->hwnd = hWnd;
		dc = GetDC(hWnd);
		priv->dcBitmap = CreateCompatibleBitmap(dc, g->g.Width, g->g.Height);
		priv->dcBuffer = CreateCompatibleDC(dc);
		ReleaseDC(hWnd, dc);
		priv->dcOldBitmap = SelectObject(priv->dcBuffer, priv->dcBitmap);

		// Mark the window as ready to go
		g->flags |= GDISP_FLG_READY;
		break;

	#if GINPUT_NEED_MOUSE || GINPUT_NEED_TOGGLE
		case WM_LBUTTONDOWN:
			// Get our GDisplay structure
			g = (GDisplay *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
			priv = (winPriv *)g->priv;

			// Handle mouse down on the window
			#if GINPUT_NEED_MOUSE
				if ((coord_t)HIWORD(lParam) < GDISP_SCREEN_HEIGHT) {
					priv->mousebuttons |= GINPUT_MOUSE_BTN_LEFT;
					goto mousemove;
				}
			#endif

			// Handle mouse down on the toggle area
			#if GINPUT_NEED_TOGGLE
				if ((coord_t)HIWORD(lParam) >= GDISP_SCREEN_HEIGHT && (g->flags & GDISP_FLG_HASTOGGLE)) {
					bit = 1 << ((coord_t)LOWORD(lParam)*8/g->g.Width);
					priv->toggles ^= bit;
					rect.left = 0;
					rect.right = GDISP_SCREEN_WIDTH;
					rect.top = GDISP_SCREEN_HEIGHT;
					rect.bottom = GDISP_SCREEN_HEIGHT + WIN32_BUTTON_AREA;
					InvalidateRect(hWnd, &rect, FALSE);
					UpdateWindow(hWnd);
					#if GINPUT_TOGGLE_POLL_PERIOD == TIME_INFINITE
						ginputToggleWakeup();
					#endif
				}
			#endif
			break;

		case WM_LBUTTONUP:
			// Get our GDisplay structure
			g = (GDisplay *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
			priv = (winPriv *)g->priv;

			// Handle mouse up on the toggle area
			#if GINPUT_NEED_TOGGLE
				if ((g->flags & GDISP_FLG_HASTOGGLE)) {
					if ((priv->toggles & 0x0F)) {
						priv->toggles &= ~0x0F;
						rect.left = 0;
						rect.right = GDISP_SCREEN_WIDTH;
						rect.top = GDISP_SCREEN_HEIGHT;
						rect.bottom = GDISP_SCREEN_HEIGHT + WIN32_BUTTON_AREA;
						InvalidateRect(hWnd, &rect, FALSE);
						UpdateWindow(hWnd);
						#if GINPUT_TOGGLE_POLL_PERIOD == TIME_INFINITE
							ginputToggleWakeup();
						#endif
					}
				}
			#endif

			// Handle mouse up on the window
			#if GINPUT_NEED_MOUSE
				if ((coord_t)HIWORD(lParam) < GDISP_SCREEN_HEIGHT) {
					priv->mousebuttons &= ~GINPUT_MOUSE_BTN_LEFT;
					goto mousemove;
				}
			#endif
			break;
	#endif

	#if GINPUT_NEED_MOUSE
		case WM_MBUTTONDOWN:
			g = (GDisplay *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
			priv = (winPriv *)g->priv;
			if ((coord_t)HIWORD(lParam) < GDISP_SCREEN_HEIGHT) {
				priv->mousebuttons |= GINPUT_MOUSE_BTN_MIDDLE;
				goto mousemove;
			}
			break;
		case WM_MBUTTONUP:
			g = (GDisplay *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
			priv = (winPriv *)g->priv;
			if ((coord_t)HIWORD(lParam) < GDISP_SCREEN_HEIGHT) {
				priv->mousebuttons &= ~GINPUT_MOUSE_BTN_MIDDLE;
				goto mousemove;
			}
			break;
		case WM_RBUTTONDOWN:
			g = (GDisplay *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
			priv = (winPriv *)g->priv;
			if ((coord_t)HIWORD(lParam) < GDISP_SCREEN_HEIGHT) {
				priv->mousebuttons |= GINPUT_MOUSE_BTN_RIGHT;
				goto mousemove;
			}
			break;
		case WM_RBUTTONUP:
			g = (GDisplay *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
			priv = (winPriv *)g->priv;
			if ((coord_t)HIWORD(lParam) < GDISP_SCREEN_HEIGHT) {
				priv->mousebuttons &= ~GINPUT_MOUSE_BTN_RIGHT;
				goto mousemove;
			}
			break;
		case WM_MOUSEMOVE:
			g = (GDisplay *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
			priv = (winPriv *)g->priv;
			if ((coord_t)HIWORD(lParam) >= GDISP_SCREEN_HEIGHT)
				break;
		mousemove:
			priv->mousex = (coord_t)LOWORD(lParam);
			priv->mousey = (coord_t)HIWORD(lParam);
			if ((gmvmt(priv->mouse)->d.flags & GMOUSE_VFLG_NOPOLL))		// For normal setup this is always TRUE
				_gmouseWakeup(priv->mouse);
			break;
	#endif

	case WM_SYSKEYDOWN:
	case WM_KEYDOWN:
	case WM_SYSKEYUP:
	case WM_KEYUP:
		break;
	case WM_CHAR:
	case WM_DEADCHAR:
	case WM_SYSCHAR:
	case WM_SYSDEADCHAR:
		break;

	case WM_ERASEBKGND:
		// Pretend we have erased the background.
		// We know we don't really need to do this as we
		// redraw the entire surface in the WM_PAINT handler.
		return TRUE;

	case WM_PAINT:
		// Get our GDisplay structure
		g = (GDisplay *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
		priv = (winPriv *)g->priv;

		// Paint the main window area
		WaitForSingleObject(drawMutex, INFINITE);
		dc = BeginPaint(hWnd, &ps);
		BitBlt(dc, ps.rcPaint.left, ps.rcPaint.top,
			ps.rcPaint.right - ps.rcPaint.left,
			(ps.rcPaint.bottom > GDISP_SCREEN_HEIGHT ? GDISP_SCREEN_HEIGHT : ps.rcPaint.bottom) - ps.rcPaint.top,
			priv->dcBuffer, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY);

		// Paint the toggle area
		#if GINPUT_NEED_TOGGLE
			if (ps.rcPaint.bottom >= GDISP_SCREEN_HEIGHT && (g->flags & GDISP_FLG_HASTOGGLE)) {
				pen = CreatePen(PS_SOLID, 1, gdispColor2Native(Black));
				hbrOn = CreateSolidBrush(gdispColor2Native(Blue));
				hbrOff = CreateSolidBrush(gdispColor2Native(Gray));
				old = SelectObject(dc, pen);
				MoveToEx(dc, 0, GDISP_SCREEN_HEIGHT, &p);
				LineTo(dc, GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT);
				for(pos = 0, bit=1; pos < wWidth; pos=rect.right, bit <<= 1) {
					rect.left = pos;
					rect.right = pos + GDISP_SCREEN_WIDTH/8;
					rect.top = GDISP_SCREEN_HEIGHT;
					rect.bottom = GDISP_SCREEN_HEIGHT + WIN32_BUTTON_AREA;
					FillRect(dc, &rect, (priv->toggles & bit) ? hbrOn : hbrOff);
					if (pos > 0) {
						MoveToEx(dc, rect.left, rect.top, &p);
						LineTo(dc, rect.left, rect.bottom);
					}
				}
				DeleteObject(hbrOn);
				DeleteObject(hbrOff);
				SelectObject(dc, old);
			}
		#endif
		EndPaint(hWnd, &ps);
		ReleaseMutex(drawMutex);
		break;

	case WM_DESTROY:
		// Get our GDisplay structure
		g = (GDisplay *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
		priv = (winPriv *)g->priv;

		// Restore the window and free our bitmaps
		SelectObject(priv->dcBuffer, priv->dcOldBitmap);
		DeleteDC(priv->dcBuffer);
		DeleteObject(priv->dcBitmap);

		// Cleanup the private area
		gfxFree(priv);

		// Quit the application
		PostQuitMessage(0);

		// Actually the above doesn't work (who knows why)
		ExitProcess(0);
		break;

	default:
		return DefWindowProc(hWnd, Msg, wParam, lParam);
	}
	return 0;
}
Example #13
0
Cgdi::Cgdi()
{
  m_BlackPen = CreatePen(PS_SOLID, 1, colors[black]);
  m_WhitePen = CreatePen(PS_SOLID, 1, colors[white]);
  m_RedPen = CreatePen(PS_SOLID, 1, colors[red]);
  m_GreenPen = CreatePen(PS_SOLID, 1, colors[green]);
  m_BluePen = CreatePen(PS_SOLID, 1, colors[blue]);
  m_GreyPen = CreatePen(PS_SOLID, 1, colors[grey]);
  m_PinkPen = CreatePen(PS_SOLID, 1, colors[pink]);
  m_YellowPen = CreatePen(PS_SOLID, 1, colors[yellow]);
  m_OrangePen = CreatePen(PS_SOLID, 1, colors[orange]);
  m_PurplePen = CreatePen(PS_SOLID, 1, colors[purple]);
  m_BrownPen = CreatePen(PS_SOLID, 1, colors[brown]);
  
  m_DarkGreenPen = CreatePen(PS_SOLID, 1, colors[dark_green]);

  m_LightBluePen = CreatePen(PS_SOLID, 1, colors[light_blue]);
  m_LightGreyPen = CreatePen(PS_SOLID, 1, colors[light_grey]);
  m_LightPinkPen = CreatePen(PS_SOLID, 1, colors[light_pink]);

  m_ThickBlackPen = CreatePen(PS_SOLID, 2, colors[black]);
  m_ThickWhitePen = CreatePen(PS_SOLID, 2, colors[white]);
  m_ThickRedPen = CreatePen(PS_SOLID, 2, colors[red]);
  m_ThickGreenPen = CreatePen(PS_SOLID, 2, colors[green]);
  m_ThickBluePen = CreatePen(PS_SOLID, 2, colors[blue]);

  m_GreenBrush = CreateSolidBrush(colors[green]);
  m_RedBrush   = CreateSolidBrush(colors[red]);
  m_BlueBrush  = CreateSolidBrush(colors[blue]);
  m_GreyBrush  = CreateSolidBrush(colors[grey]);
  m_BrownBrush = CreateSolidBrush(colors[brown]);
  m_YellowBrush = CreateSolidBrush(colors[yellow]);
  m_LightBlueBrush = CreateSolidBrush(colors[light_blue]);
  m_DarkGreenBrush = CreateSolidBrush(colors[dark_green]);
  m_OrangeBrush = CreateSolidBrush(colors[orange]);
  m_PurpleBrush = CreateSolidBrush(colors[purple]);

  m_tmpPen = CreatePen(PS_SOLID,1,RGB(0,0,0));
  m_tmpBrush = CreateSolidBrush(RGB(0,0,0));

  m_hdc = NULL;
}
Example #14
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static POINT point;
	static POINT pointOld;
	static BOOL bCapture;
	static HFONT hFont;
	static TCHAR szText[1024];
	switch (msg)
	{
	case WM_CREATE:
		hFont = CreateFont(64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TEXT("メイリオ"));
		break;
	case WM_LBUTTONDOWN:
		if (!bCapture)
		{
			point.x = LOWORD(lParam);
			point.y = HIWORD(lParam);
			SetCapture(hWnd);
			bCapture = 1;
		}
		break;
	case WM_RBUTTONUP:
		if (bCapture)
		{
			ReleaseCapture();
			bCapture = 0;
		}
		SendMessage(hWnd, WM_CLOSE, 0, 0);
		break;
	case WM_PAINT:
	{
		PAINTSTRUCT ps;
		const HDC hdc = BeginPaint(hWnd, &ps);
		const HFONT hFontOld = (HFONT)SelectObject(hdc, hFont);
		RECT rect;
		GetClientRect(hWnd, &rect);
		DrawText(hdc, szText, -1, &rect, DT_WORDBREAK);
		SelectObject(hdc, hFontOld);
		EndPaint(hWnd, &ps);
	}
	break;
	case WM_MOUSEMOVE:
		if (bCapture)
		{
			const HDC hdc = GetDC(hWnd);
			const HPEN hPen = CreatePen(PS_SOLID, 1, RGB(255, 255, 255));
			const HPEN hPenOld = (HPEN)SelectObject(hdc, hPen);
			MoveToEx(hdc, point.x, point.y, 0);
			LineTo(hdc, pointOld.x, pointOld.y);
			SelectObject(hdc, hPenOld);
			DeleteObject(hPen);
			MoveToEx(hdc, point.x, point.y, 0);
			LineTo(hdc, LOWORD(lParam), HIWORD(lParam));
			const HFONT hFontOld = (HFONT)SelectObject(hdc, hFont);
			const double dAngle = atan2((double)(point.x - LOWORD(lParam)), (double)(point.y - HIWORD(lParam)));
			const double dDistance = sqrt((double)((point.x - LOWORD(lParam))*(point.x - LOWORD(lParam)) + (point.y - HIWORD(lParam))*(point.y - HIWORD(lParam))));
			swprintf_s(szText, 1024,
				TEXT("角度 %f 度\r\n")
				TEXT("角度 %f ラジアン\r\n")
				TEXT("距離 %f ピクセル\r\n"),
				(dAngle + PI / 2.0)*180.0 / PI,
				dAngle + PI / 2.0,
				dDistance + 1.0
				);
			RECT rect;
			GetClientRect(hWnd, &rect);
			DrawText(hdc, szText, -1, &rect, DT_WORDBREAK);
			SelectObject(hdc, hFontOld);
			ReleaseDC(hWnd, hdc);
			pointOld.x = LOWORD(lParam);
			pointOld.y = HIWORD(lParam);
		}
		break;
	case WM_LBUTTONUP:
		if (bCapture)
		{
			ReleaseCapture();
			bCapture = 0;
			InvalidateRect(hWnd, 0, 1);
		}
		break;
	case WM_KEYDOWN:
		if (wParam == VK_ESCAPE)
		{
			SendMessage(hWnd, WM_CLOSE, 0, 0);
		}
		else if (wParam == 'C')
		{
			if (GetKeyState(VK_CONTROL)<0)
			{
				const int nLen = lstrlen(szText);
				const HGLOBAL hMem = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, sizeof(TCHAR)*(nLen + 1));
				const LPTSTR lpszBuf = (LPTSTR)GlobalLock(hMem);
				lstrcpy(lpszBuf, szText);
				GlobalUnlock(hMem);
				OpenClipboard(NULL);
				EmptyClipboard();
				SetClipboardData(CF_UNICODETEXT, hMem);
				CloseClipboard();
			}
		}
		break;
	case WM_DESTROY:
		DeleteObject(hFont);
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, msg, wParam, lParam);
	}
	return 0;
}
Example #15
0
LRESULT OnPaint(HWND hWnd,WPARAM wParam,LPARAM lParam)
{
    HDC hdc;
    PAINTSTRUCT ps;
    int idx;
    HPEN hPen,hOldPen;
    HBRUSH hBrush,hOldBrush;
    RECT crt;
    HDC hMemDC;
    HBITMAP hOldBitmap;
    int x,y;
    BITMAPFILEHEADER *fh;
    BITMAPINFOHEADER *ih;
    int bx,by;
    BYTE *pRaster;
    HFONT hFont,hOldFont;
    int FontHeight;
    int FontIdx;
    LOGFONT tFont;

    hdc=BeginPaint(hWnd, &ps);
    hMemDC=CreateCompatibleDC(hdc);
    GetClientRect(hWnd,&crt);
    if (hBackBit == NULL) {
        hBackBit=CreateCompatibleBitmap(hdc,crt.right,crt.bottom);
    }
    hOldBitmap=(HBITMAP)SelectObject(hMemDC,hBackBit);
    FillRect(hMemDC,&crt,GetSysColorBrush(COLOR_WINDOW));

    if (bGridLine) {
        hPen=CreatePen(PS_SOLID,1,RGB(192,192,192));
        hOldPen=(HPEN)SelectObject(hMemDC,hPen);
        for (y=0; y<crt.bottom; y=y+GridLineY*GridY) {
            MoveToEx(hMemDC,0,y,NULL);
            LineTo(hMemDC,crt.right,y);
        }
        for (x=0; x<crt.right; x=x+GridLineX*GridX) {
            MoveToEx(hMemDC,x,0,NULL);
            LineTo(hMemDC,x,crt.bottom);
        }
        DeleteObject(SelectObject(hMemDC,hOldPen));
    }

    SetStretchBltMode(hMemDC,StretchMode);
    SetBkMode(hMemDC,TRANSPARENT);
    for (idx=0; idx<arNum; idx++) {
        if (arObj[idx]->LineColor == (COLORREF)-1) {
            hPen=(HPEN)GetStockObject(NULL_PEN);
        } else {
            hPen=CreatePen(PS_INSIDEFRAME,arObj[idx]->LineWidth,arObj[idx]->LineColor);
        }
        hOldPen=(HPEN)SelectObject(hMemDC,hPen);
        if (arObj[idx]->PlaneColor == (COLORREF)-1) {
            hBrush=(HBRUSH)GetStockObject(NULL_BRUSH);
        } else {
            hBrush=CreateSolidBrush(arObj[idx]->PlaneColor);
        }
        hOldBrush=(HBRUSH)SelectObject(hMemDC,hBrush);
        switch (arObj[idx]->Type) {
        case DT_LINE:
            if ((arObj[idx]->Flag & 0x3) == DS_LT || (arObj[idx]->Flag & 0x3) == DS_RB) {
                MoveToEx(hMemDC,arObj[idx]->rt.left,arObj[idx]->rt.top,NULL);
                LineTo(hMemDC,arObj[idx]->rt.right,arObj[idx]->rt.bottom);
            } else {
                MoveToEx(hMemDC,arObj[idx]->rt.left,arObj[idx]->rt.bottom,NULL);
                LineTo(hMemDC,arObj[idx]->rt.right,arObj[idx]->rt.top);
            }
            break;
        case DT_ELLIPSE:
            Ellipse(hMemDC,arObj[idx]->rt.left,arObj[idx]->rt.top,
                    arObj[idx]->rt.right,arObj[idx]->rt.bottom);
            break;
        case DT_RECTANGLE:
            Rectangle(hMemDC,arObj[idx]->rt.left,arObj[idx]->rt.top,
                      arObj[idx]->rt.right,arObj[idx]->rt.bottom);
            break;
        case DT_BITMAP:
            fh=(BITMAPFILEHEADER *)arObj[idx]->Bitmap;
            pRaster=(PBYTE)fh+fh->bfOffBits;
            ih=(BITMAPINFOHEADER *)((PBYTE)fh+sizeof(BITMAPFILEHEADER));
            bx=ih->biWidth;
            by=ih->biHeight;
            StretchDIBits(hMemDC,arObj[idx]->rt.left,arObj[idx]->rt.top,
                          arObj[idx]->rt.right-arObj[idx]->rt.left,
                          arObj[idx]->rt.bottom-arObj[idx]->rt.top,0,0,bx,by,
                          pRaster,(BITMAPINFO *)ih,DIB_RGB_COLORS,SRCCOPY);
            break;
        case DT_META:
            PlayPlaceableMeta(hMemDC,arObj[idx]->Meta,arObj[idx]->Len,&arObj[idx]->rt);
            break;
        case DT_TEXT:
            FillRect(hMemDC,&arObj[idx]->rt,hBrush);
            FontHeight=arObj[idx]->FontSize*GetDeviceCaps(hMemDC,LOGPIXELSY)/72;
            FontIdx=FindFontFromFace(arObj[idx]->FontFace);
            if (FontIdx!=-1) {
                tFont=logfont[FontIdx];
                tFont.lfHeight=FontHeight;
                tFont.lfWidth=0;
                hFont=CreateFontIndirect(&tFont);
                hOldFont=(HFONT)SelectObject(hMemDC,hFont);
            }
            if (arObj[idx]->FontColor != (COLORREF)-1) {
                SetTextColor(hMemDC,arObj[idx]->FontColor);
                DrawText(hMemDC,arObj[idx]->Text,-1,&arObj[idx]->rt,DT_WORDBREAK);
            }
            if (FontIdx!=-1) {
                DeleteObject(SelectObject(hMemDC,hOldFont));
            }
            break;
        }
        SelectObject(hMemDC,hOldPen);
        SelectObject(hMemDC,hOldBrush);
        if (arObj[idx]->LineColor != (COLORREF)-1) {
            DeleteObject(hPen);
        }
        if (arObj[idx]->PlaneColor != (COLORREF)-1) {
            DeleteObject(hBrush);
        }
    }
    if (NowSel != -1) {
        DrawTracker(hMemDC,NowSel);
    }
    BitBlt(hdc,0,0,crt.right,crt.bottom,hMemDC,0,0,SRCCOPY);
    SelectObject(hMemDC,hOldBitmap);
    DeleteDC(hMemDC);
    EndPaint(hWnd, &ps);
    return 0;
}
Example #16
0
//------------------------------------------------------------------------
// Paint the keyframe data graph.
// ----------------------------------------------------------------------
// Param -> IN:
//      HWND:       Destinate window to paint.
//      GRAPH_TYPE: Type of the graph to paint.
//------------------------------------------------------------------------
void CAppKFManager::PaintGraph( HWND hWnd,enum GRAPH_TYPE Type )
{
    int n;
    POINT ptCur,ptNew;
    float fTime1,fTime2;
    float fValue1,fValue2;
    FlyVector v1,v2;
    FLYCOLOR c1,c2;

    HDC hdc = GetDC( hWnd );

    // Create some Pens.
    HPEN hR = CreatePen( PS_SOLID,0,RGB(255,0,0) );
    HPEN hG = CreatePen( PS_SOLID,0,RGB(0,255,0) );
    HPEN hB = CreatePen( PS_SOLID,0,RGB(0,0,255) );

    // First, paint rectangle. Our graphs
    // are in it.
    Rectangle( hdc,20,220,260,340 );

    switch( Type )
    {
    case GRAPH_SIZE:
        for( n=0;n<m_Particle.GetKFSizeArray()->size()-1;n++ )
        {
            SelectObject( hdc,hR );

            fTime1 = ((*m_Particle.GetKFSizeArray())[n]).fTime;
            fValue1 = ((*m_Particle.GetKFSizeArray())[n]).fSize;
            ptCur.x = 20 + 240 * fTime1;
            ptCur.y = 340 - 120 * (fValue1/10.0f);
            MoveToEx( hdc,ptCur.x,ptCur.y,NULL );

            fTime2 = ((*m_Particle.GetKFSizeArray())[n+1]).fTime;
            fValue1 = ((*m_Particle.GetKFSizeArray())[n+1]).fSize;
            ptNew.x = 20 + 240 * fTime2;
            ptNew.y = 340 - 120 * (fValue1/10.0f);
            LineTo( hdc,ptNew.x,ptNew.y );
        }
        break;
    case GRAPH_ANGLE:
        for( n=0;n<m_Particle.GetKFAngleArray()->size()-1;n++ )
        {
            SelectObject( hdc,hR );

            fTime1 = ((*m_Particle.GetKFAngleArray())[n]).fTime;
            fValue1 = ((*m_Particle.GetKFAngleArray())[n]).fAngle;
            ptCur.x = 20 + 240 * fTime1;
            ptCur.y = 280 - 60 * (fValue1/10.0f);
            MoveToEx( hdc,ptCur.x,ptCur.y,NULL );

            fTime2 = ((*m_Particle.GetKFAngleArray())[n+1]).fTime;
            fValue1 = ((*m_Particle.GetKFAngleArray())[n+1]).fAngle;
            ptNew.x = 20 + 240 * fTime2;
            ptNew.y = 280 - 60 * (fValue1/10.0f);
            LineTo( hdc,ptNew.x,ptNew.y );
        }
        break;
    case GRAPH_ALPHA:
        for( n=0;n<m_Particle.GetKFAlphaArray()->size()-1;n++ )
        {
            SelectObject( hdc,hR );

            fTime1 = ((*m_Particle.GetKFAlphaArray())[n]).fTime;
            fValue1 = ((*m_Particle.GetKFAlphaArray())[n]).fAlpha;
            ptCur.x = 20 + 240 * fTime1;
            ptCur.y = 340 - 120 * fValue1;
            MoveToEx( hdc,ptCur.x,ptCur.y,NULL );

            fTime2 = ((*m_Particle.GetKFAlphaArray())[n+1]).fTime;
            fValue1 = ((*m_Particle.GetKFAlphaArray())[n+1]).fAlpha;
            ptNew.x = 20 + 240 * fTime2;
            ptNew.y = 340 - 120 * fValue1;
            LineTo( hdc,ptNew.x,ptNew.y );
        }
        break;
    case GRAPH_COLOR:
        for( n=0;n<m_Particle.GetKFColorArray()->size()-1;n++ )
        {
            fTime1 = ((*m_Particle.GetKFColorArray())[n]).fTime;
            c1 = ((*m_Particle.GetKFColorArray())[n]).cColor;
            fTime2 = ((*m_Particle.GetKFColorArray())[n+1]).fTime;
            c2 = ((*m_Particle.GetKFColorArray())[n+1]).cColor;

            SelectObject( hdc,hR );
            ptCur.x = 20 + 240 * fTime1;
            ptCur.y = 340 - 120 * c1.fR;
            ptNew.x = 20 + 240 * fTime2;
            ptNew.y = 340 - 120 * c2.fR;
            MoveToEx( hdc,ptCur.x,ptCur.y,NULL );
            LineTo( hdc,ptNew.x,ptNew.y );

            SelectObject( hdc,hG );
            ptCur.x = 20 + 240 * fTime1;
            ptCur.y = 340 - 120 * c1.fG;
            ptNew.x = 20 + 240 * fTime2;
            ptNew.y = 340 - 120 * c2.fG;
            MoveToEx( hdc,ptCur.x,ptCur.y,NULL );
            LineTo( hdc,ptNew.x,ptNew.y );

            SelectObject( hdc,hB );
            ptCur.x = 20 + 240 * fTime1;
            ptCur.y = 340 - 120 * c1.fB;
            ptNew.x = 20 + 240 * fTime2;
            ptNew.y = 340 - 120 * c2.fB;
            MoveToEx( hdc,ptCur.x,ptCur.y,NULL );
            LineTo( hdc,ptNew.x,ptNew.y );
        }
        break;
    case GRAPH_LIFE:
        for( n=0;n<m_Emitter.GetKFLifeArray()->size()-1;n++ )
        {
            fTime1 = ((*m_Emitter.GetKFLifeArray())[n]).fTime;
            fValue1 = ((*m_Emitter.GetKFLifeArray())[n]).fLifeMin;
            fTime2 = ((*m_Emitter.GetKFLifeArray())[n+1]).fTime;
            fValue2 = ((*m_Emitter.GetKFLifeArray())[n+1]).fLifeMin;

            SelectObject( hdc,hR );
            ptCur.x = 20 + 240 * fTime1;
            ptCur.y = 340 - 120 * (fValue1/20.0f);
            MoveToEx( hdc,ptCur.x,ptCur.y,NULL );
            ptNew.x = 20 + 240 * fTime2;
            ptNew.y = 340 - 120 * (fValue2/20.0f);
            LineTo( hdc,ptNew.x,ptNew.y );

            fValue1 = ((*m_Emitter.GetKFLifeArray())[n]).fLifeMax;
            fValue2 = ((*m_Emitter.GetKFLifeArray())[n+1]).fLifeMax;

            SelectObject( hdc,hG );
            ptCur.x = 20 + 240 * fTime1;
            ptCur.y = 340 - 120 * (fValue1/20.0f);
            MoveToEx( hdc,ptCur.x,ptCur.y,NULL );
            ptNew.x = 20 + 240 * fTime2;
            ptNew.y = 340 - 120 * (fValue2/20.0f);
            LineTo( hdc,ptNew.x,ptNew.y );
        }
        break;
    case GRAPH_VELOCITY:
        for( n=0;n<m_Emitter.GetKFVelocityArray()->size()-1;n++ )
        {
            fTime1 = ((*m_Emitter.GetKFVelocityArray())[n]).fTime;
            fValue1 = ((*m_Emitter.GetKFVelocityArray())[n]).fVelocityMin;
            fTime2 = ((*m_Emitter.GetKFVelocityArray())[n+1]).fTime;
            fValue2 = ((*m_Emitter.GetKFVelocityArray())[n+1]).fVelocityMin;

            SelectObject( hdc,hR );
            ptCur.x = 20 + 240 * fTime1;
            ptCur.y = 340 - 120 * (fValue1/10.0f);
            MoveToEx( hdc,ptCur.x,ptCur.y,NULL );
            ptNew.x = 20 + 240 * fTime2;
            ptNew.y = 340 - 120 * (fValue2/10.0f);
            LineTo( hdc,ptNew.x,ptNew.y );

            fValue1 = ((*m_Emitter.GetKFVelocityArray())[n]).fVelocityMax;
            fValue2 = ((*m_Emitter.GetKFVelocityArray())[n+1]).fVelocityMax;

            SelectObject( hdc,hG );
            ptCur.x = 20 + 240 * fTime1;
            ptCur.y = 340 - 120 * (fValue1/10.0f);
            MoveToEx( hdc,ptCur.x,ptCur.y,NULL );
            ptNew.x = 20 + 240 * fTime2;
            ptNew.y = 340 - 120 * (fValue2/10.0f);
            LineTo( hdc,ptNew.x,ptNew.y );
        }
        break;
    case GRAPH_VELOCITYDIR:
        for( n=0;n<m_Emitter.GetKFVelocityDirArray()->size()-1;n++ )
        {
            fTime1 = ((*m_Emitter.GetKFVelocityDirArray())[n]).fTime;
            v1 = ((*m_Emitter.GetKFVelocityDirArray())[n]).vVelocityDir;
            fTime2 = ((*m_Emitter.GetKFVelocityDirArray())[n+1]).fTime;
            v2 = ((*m_Emitter.GetKFVelocityDirArray())[n+1]).vVelocityDir;

            SelectObject( hdc,hR );
            ptCur.x = 20 + 240 * fTime1;
            ptCur.y = 280 - 60 * (v1.x/10.0f);
            MoveToEx( hdc,ptCur.x,ptCur.y,NULL );
            ptNew.x = 20 + 240 * fTime2;
            ptNew.y = 280 - 60 * (v2.x/10.0f);
            LineTo( hdc,ptNew.x,ptNew.y );

            SelectObject( hdc,hG );
            ptCur.x = 20 + 240 * fTime1;
            ptCur.y = 280 - 60 * (v1.y/10.0f);
            MoveToEx( hdc,ptCur.x,ptCur.y,NULL );
            ptNew.x = 20 + 240 * fTime2;
            ptNew.y = 280 - 60 * (v2.y/10.0f);
            LineTo( hdc,ptNew.x,ptNew.y );

            SelectObject( hdc,hB );
            ptCur.x = 20 + 240 * fTime1;
            ptCur.y = 280 - 60 * (v1.z/10.0f);
            MoveToEx( hdc,ptCur.x,ptCur.y,NULL );
            ptNew.x = 20 + 240 * fTime2;
            ptNew.y = 280 - 60 * (v2.z/10.0f);
            LineTo( hdc,ptNew.x,ptNew.y );
        }
        break;
    case GRAPH_EMITRATE:
        for( n=0;n<m_Emitter.GetKFEmitRateArray()->size()-1;n++ )
        {
            fTime1 = ((*m_Emitter.GetKFEmitRateArray())[n]).fTime;
            fValue1 = ((*m_Emitter.GetKFEmitRateArray())[n]).fEmitRateMin;
            fTime2 = ((*m_Emitter.GetKFEmitRateArray())[n+1]).fTime;
            fValue2 = ((*m_Emitter.GetKFEmitRateArray())[n+1]).fEmitRateMin;

            SelectObject( hdc,hR );
            ptCur.x = 20 + 240 * fTime1;
            ptCur.y = 340 - 120 * (fValue1/100.0f);
            MoveToEx( hdc,ptCur.x,ptCur.y,NULL );
            ptNew.x = 20 + 240 * fTime2;
            ptNew.y = 340 - 120 * (fValue2/100.0f);
            LineTo( hdc,ptNew.x,ptNew.y );

            fValue1 = ((*m_Emitter.GetKFEmitRateArray())[n]).fEmitRateMax;
            fValue2 = ((*m_Emitter.GetKFEmitRateArray())[n+1]).fEmitRateMax;

            SelectObject( hdc,hG );
            ptCur.x = 20 + 240 * fTime1;
            ptCur.y = 340 - 120 * (fValue1/100.0f);
            MoveToEx( hdc,ptCur.x,ptCur.y,NULL );
            ptNew.x = 20 + 240 * fTime2;
            ptNew.y = 340 - 120 * (fValue2/100.0f);
            LineTo( hdc,ptNew.x,ptNew.y );
        }
        break;
    }

    // Release the resources.
    DeleteObject( hR );
    DeleteObject( hG );
    DeleteObject( hB );
    ReleaseDC( hWnd,hdc );
}
Example #17
0
void PaintCandWindow( HWND hCandWnd)
{
	PAINTSTRUCT ps;
	HIMC hIMC = NULL;
	LPINPUTCONTEXT lpIMC = NULL;
	LPCANDIDATEINFO lpCandInfo = NULL;
	LPCANDIDATELIST lpCandList = NULL;
	HDC hDC = NULL;
	HFONT oldFont = NULL;
	RECT rc;
	LPTSTR lpstr = NULL;
	TCHAR szStr[100];
	int height,width;
	DWORD i;
	SIZE sz;
	HWND hSvrWnd = NULL;
	HBRUSH hBrush = NULL, hOldBrush = NULL;	
	HPEN hPen = NULL, hOldPen = NULL;	 

	hDC = BeginPaint(hCandWnd,&ps);
	oldFont = (HFONT)SelectObject(hDC, hUIFont);

	GetClientRect(hCandWnd,&rc);
	hBrush = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
	hOldBrush = (HBRUSH)SelectObject(hDC,hBrush);
	PatBlt(hDC,	rc.left, rc.top ,	rc.right, rc.bottom, PATCOPY);
	if(hBrush && hOldBrush)
	{
		SelectObject(hDC,hOldBrush);
	}

	hPen = (HPEN)GetStockObject(WHITE_PEN);
	hOldPen = (HPEN)SelectObject(hDC,hPen);
	MoveToEx(hDC,0,rc.bottom - GetSystemMetrics(SM_CXEDGE)/2,NULL);
	LineTo(hDC,rc.right-GetSystemMetrics(SM_CXEDGE)/2,rc.bottom - GetSystemMetrics(SM_CXEDGE)/2);
	LineTo(hDC,rc.right-GetSystemMetrics(SM_CXEDGE)/2,0);

	hPen = CreatePen(PS_SOLID ,0,RGB(128,128,128));
	SelectObject(hDC,hPen);
	MoveToEx(hDC,rc.right-GetSystemMetrics(SM_CXEDGE)/2,0,NULL);
	LineTo(hDC,0,0);
	LineTo(hDC,0,rc.bottom-GetSystemMetrics(SM_CYEDGE)/2);

	SelectObject(hDC,hOldPen);
	DeleteObject(hPen);

	hSvrWnd = (HWND)GetWindowLong(hCandWnd,FIGWL_SVRWND);

	if (hIMC = (HIMC)GetWindowLong(hSvrWnd,IMMGWL_IMC))
	{
		lpIMC = ImmLockIMC(hIMC);
		if (lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo))
		{
			DWORD dwMaxPaintPos;
			WORD  wCount;

			height = 3;
			width = 1;
			lpCandList = (LPCANDIDATELIST)((LPTSTR)lpCandInfo  + lpCandInfo->dwOffset[0]);
			SetBkMode(hDC, TRANSPARENT);
			SetPaintColor(hDC, wConversionMode);

			if(wConversionSet & CONVERSION_SET_SHAPE) 
			{
				lpstr = GETLPCANDSTR(lpCandList, 0);
				TextOut(hDC, width, height, lpstr, _tcslen(lpstr));
				GetTextExtentPoint(hDC, lpstr, _tcslen(lpstr), &sz);
				width += sz.cx * 3 / 2;
			}

			dwMaxPaintPos = lpCandList->dwPageStart +lpCandList->dwPageSize ;
			if(dwMaxPaintPos > lpCandList->dwCount + 2)  
				dwMaxPaintPos = lpCandList->dwCount + 2;

			wCount = 0;
			for (i = lpCandList->dwPageStart; i < dwMaxPaintPos; i++)
			{
				wCount++;
				lpstr = GETLPCANDSTR(lpCandList,i);
				GetTextExtentPoint(hDC,lpstr, _tcslen(lpstr), &sz);
				if(wConversionSet & CONVERSION_SET_SHAPE) 
				{
					_stprintf(szStr, TEXT("%d%s "), wCount % 10, lpstr);
					TextOut(hDC,width,height,szStr,_tcslen(szStr));
					GetTextExtentPoint(hDC,szStr,_tcslen(szStr),&sz);
					width += sz.cx;
				}
				else 
				{
					_stprintf(szStr,TEXT("%d %s "), wCount%10,lpstr);
					TextOut(hDC,width,height,szStr,_tcslen(szStr));
					GetTextExtentPoint(hDC,szStr,_tcslen(szStr),&sz);
					height += sz.cy;
				}
			}
			if(wConversionSet & CONVERSION_SET_SHAPE) 
			{
				lpstr = GETLPCANDSTR(lpCandList, 1);
				if(_tcslen(lpstr)) 
				{
					GetTextExtentPoint(hDC, TEXT("A"), 1, &sz);
					width = sizeCand[1].cx - sz.cx * 3 / 2;
					TextOut(hDC, width, height, lpstr, _tcslen(lpstr));
				}
			}

			ImmUnlockIMCC(lpIMC->hCandInfo);
		}
		ImmUnlockIMC(hIMC);
	}
	SelectObject(hDC, oldFont);
	EndPaint(hCandWnd, &ps);
}
Example #18
0
LRESULT CALLBACK TranslateDlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
	
	char sztemp[20];
	TRANSLATEOBJ * st;
	
	st = (TRANSLATEOBJ *) actobject;
    if ((st==NULL)||(st->type!=OB_TRANSLATE)) return(FALSE);

	switch( message )
	{
		case WM_INITDIALOG:
			sprintf(sztemp,"%.2f",st->in_ports[0].in_min);
			SetDlgItemText(hDlg, IDC_IN_MIN, sztemp);
			sprintf(sztemp,"%.2f",st->in_ports[0].in_max);
			SetDlgItemText(hDlg, IDC_IN_MAX, sztemp);
			sprintf(sztemp,"%.2f",st->out_ports[0].out_min);
			SetDlgItemText(hDlg, IDC_OUT_MIN, sztemp);
			sprintf(sztemp,"%.2f",st->out_ports[0].out_max);
			SetDlgItemText(hDlg, IDC_OUT_MAX, sztemp);
			
			return TRUE;
		case WM_CLOSE:		
			    EndDialog(hDlg, LOWORD(wParam));
				return TRUE;
				break;
		case WM_COMMAND:
			switch (LOWORD(wParam)) 
			{
			case IDC_APPLY:
				st->in_ports[0].get_range=-1;
				st->out_ports[0].get_range=-1;
				GetDlgItemText(hDlg,IDC_IN_MIN,sztemp,sizeof(sztemp));
				sscanf(sztemp,"%f",&st->in_ports[0].in_min);
				GetDlgItemText(hDlg,IDC_IN_MAX,sztemp,sizeof(sztemp));
				sscanf(sztemp,"%f",&st->in_ports[0].in_max);
				GetDlgItemText(hDlg,IDC_OUT_MIN,sztemp,sizeof(sztemp));
				sscanf(sztemp,"%f",&st->out_ports[0].out_min);
				GetDlgItemText(hDlg,IDC_OUT_MAX,sztemp,sizeof(sztemp));
				sscanf(sztemp,"%f",&st->out_ports[0].out_max);
				break;

			}
			return TRUE;
		
    
	 	case WM_LBUTTONUP: st->setpoint=-1;
				break;
 	 	case WM_LBUTTONDOWN:
			{  int minpoint,i,z;
			   float actdist,mindist,actx,acty;

				  st->actmousex=(int)LOWORD(lParam);
				  st->actmousey=(int)HIWORD(lParam);
				  if ((st->actmousex<left)||(st->actmousex>right)||
					  (st->actmousey>bottom)||(st->actmousey<top)) break;
				  
				  mindist=10000;minpoint=-1;
				  actx=(float)(st->actmousex-left)/(right-left)*1023.0f;
				  acty=(float)(bottom-st->actmousey)/(bottom-top);

				  for (i=0;i<st->points;i++)
				  {
					  
				       actdist = (st->pointx[i]-actx)*(st->pointx[i]-actx)
						   + (st->pointy[i]-acty)*(st->pointy[i]-acty);
				
					   if (actdist<mindist) { mindist=actdist; minpoint=i; }

				  }

				  if (mindist<300) st->setpoint=minpoint; 
				  else 
				  { 
					 if (st->points>=MAX_TRANSLATIONPOINTS-1) break;
					
					 i=0;while ((st->pointx[i]<actx)&&(i<st->points)) i++;
					 for (z=st->points;z>i;z--)
					 {
					    st->pointx[z]=st->pointx[z-1];
					    st->pointy[z]=st->pointy[z-1];
					 }
					 st->pointx[z]=(int)actx;
					 st->pointy[z]=acty;
					 st->points++;
					 InvalidateRect(hDlg,NULL,TRUE);
					 st->setpoint=z;
				  }
			}

		case WM_MOUSEMOVE:
			{ 
				int i;
				st->actmousex=(int)LOWORD(lParam);
				st->actmousey=(int)HIWORD(lParam);
				  
				if (st->setpoint!=-1)
				{
					if ((st->actmousex<left)||(st->actmousex>right)||
					   (st->actmousey>bottom)||(st->actmousey<top))
					{
						if (st->points<=2) break;
						for (i=st->setpoint;i<st->points;i++)
						{
							st->pointx[i]=st->pointx[i+1];
							st->pointy[i]=st->pointy[i+1];
						}
						st->points--;
						st->pointx[0]=0;st->pointx[st->points-1]=1023;
						st->setpoint=-1;
					}
					else
					{
						st->pointx[st->setpoint]=(int)((st->actmousex-left)/(float)(right-left)*1023.0f);
						st->pointy[st->setpoint]=(float)(bottom-st->actmousey)/(bottom-top);
						if (st->setpoint==0) st->pointx[0]=0;
						if (st->setpoint==st->points-1) st->pointx[st->points-1]=1023;
					}
					st->calculate_map();
					sprintf(sztemp,"%.4f",((float)(st->pointx[st->setpoint])/1023*(st->in_ports[0].in_max-st->in_ports[0].in_min)+st->in_ports[0].in_min));
					SetDlgItemText(hDlg,IDC_ACT_INPUT,sztemp);

					sprintf(sztemp,"%.4f",st->pointy[st->setpoint]*(st->out_ports[0].out_max-st->out_ports[0].out_min)+st->out_ports[0].out_min);
					SetDlgItemText(hDlg,IDC_ACT_OUTPUT,sztemp);
 					InvalidateRect(hDlg,NULL,TRUE);
				}
			}
			break;


		case WM_PAINT:
			{
				PAINTSTRUCT ps;
				HDC hdc;
				RECT rect;
				HPEN tpen;
				HBRUSH tbrush;
				int i;
				float dx,dy;

				hdc = BeginPaint (hDlg, &ps);
				GetClientRect(hDlg, &rect);
				top=(int)rect.top+50;
				bottom=(int)rect.bottom-50;
				left=(int)rect.left+85;
				right=(int)rect.right-20;


				tpen    = CreatePen (PS_SOLID,3,50);
				SelectObject (hdc, tpen);
				SelectObject (hdc, DRAW.brush_ltorange);
				
				tbrush = CreateSolidBrush(PALETTERGB(240,240,240));
				SelectObject (hdc, tbrush);
				
				Rectangle(hdc,left,top,right,bottom);
				
				dx=(float)(right-left)/1023.0f;
				dy=(float)(bottom-top);

				DeleteObject(tpen);
				tpen = CreatePen (PS_SOLID,2,PALETTERGB(180,0,0));
				SelectObject (hdc, tpen);

				for (i=0;i<st->points-1;i++)
				{
					MoveToEx(hdc,left+ (int)((float)st->pointx[i]*dx),bottom - (int)(st->pointy[i]*dy),NULL);
					LineTo(hdc,left + (int)((float)st->pointx[i+1]*dx),bottom - (int)(st->pointy[i+1]*dy));
				}
				DeleteObject(tbrush);
				DeleteObject(tpen);
				EndPaint(hDlg, &ps );
			} 
			break;

		case WM_SIZE:
		case WM_MOVE:  update_toolbox_position(hDlg);
			break;
		
	
	}
    return FALSE;
}
Example #19
0
// The procedure that take care of the display
LRESULT CALLBACK GraphProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    HDC hdc;
    hdc = (HDC) wParam;
    static float max = 0., min = 0.;
    float temp_max, temp_min;
    float cur_data;
    float offset, scale, y;
    float x, inc;
    int i, j;
    int start_i;
    char temp[32];
    HPEN hp2px, hpOld;
    SIZE sz;

    // Draw a white rectangle on the default Device Context
    Rectangle(hdc, 0, 0, GRAPH_WIDTH, GRAPH_HEIGHT);

    // Initialize data
    start_i = cur_i - n_data;
    if (start_i < 0)
       start_i += n_data;
    i = n_data;
    j = start_i;
    temp_max = _data[j];
    temp_min = temp_max;

    // Calculate the minimum and the maximum of the graph
    while(i--)
    {
         cur_data = _data[j++];
         if (temp_max < cur_data)
            temp_max = cur_data;
         if (temp_min > cur_data)
            temp_min = cur_data;
         if (j == n_data)
            j = 0;
    }

    // Update the maximum
    if (max < temp_max)
      max = temp_max;
    else
      max = temp_max + (max - temp_max)*0.9;

    // Update the minimum
    if (min > temp_min)
      min = temp_min;
    else
      min = temp_min - (temp_min - min)*0.9;

    // Set the scaling of the graph
    scale = (GRAPH_HEIGHT-GRAPH_MARGIN*2)/(max-min);
    // Set the offset of the graph
    offset = GRAPH_MARGIN + max*scale;

    // Draw the vertical axis
    MoveToEx(hdc, GRAPH_MARGIN, GRAPH_MARGIN, NULL);
    LineTo(hdc, GRAPH_MARGIN, GRAPH_HEIGHT - GRAPH_MARGIN);

    // Draw the horizontal axis
    MoveToEx(hdc, GRAPH_MARGIN, offset, NULL);
    LineTo(hdc, GRAPH_WIDTH - GRAPH_MARGIN, offset);

    // Gradations
    // Initialization
    inc = ((float) GRAPH_WIDTH - 2*GRAPH_MARGIN)/((float) n_data);
    MoveToEx(hdc, GRAPH_MARGIN, offset - _data[0]*scale, NULL);
    x = GRAPH_MARGIN;
    i = n_data;
    j = start_i;

    // Use a new pen
    hp2px = CreatePen(PS_SOLID, 1, 0xFF0000);
    hpOld = SelectObject(hdc, hp2px);

    // Draw the graph
    while(i--)
    {
        y = offset - _data[j++]*scale;
        LineTo(hdc, (int) x, y);
        x += inc;
        if (j == n_data)
           j = 0;
    }
    // Delete the pen
    DeleteObject(hp2px);

    // Use another pen
    hp2px = CreatePen(PS_DOT, 1, 0xAAAAAA);
    SelectObject(hdc, hp2px);

    // Change the color of the text
    SetTextColor(hdc, 0xAAAAAA);
    SetBkMode(hdc, TRANSPARENT);
    // Draw the gradations
    for(i=-(GRAPH_HEIGHT - GRAPH_MARGIN); i<(GRAPH_HEIGHT - GRAPH_MARGIN); i += (GRAPH_HEIGHT - 2*GRAPH_MARGIN)/5)
    {
       sprintf(temp, "%.1e", (offset-i)/scale);
       GetTextExtentPoint32(hdc, temp, strlen(temp) , &sz);

       TextOut(hdc, 0, i-sz.cy/2, temp, strlen(temp));

       MoveToEx(hdc, MAX(GRAPH_MARGIN, sz.cx) + 2, i, NULL);
       LineTo(hdc, GRAPH_WIDTH - GRAPH_MARGIN, i);
    }

    // Delete the pen
    SelectObject(hdc, hpOld);
    DeleteObject(hp2px);

    return DefWindowProc(hwnd, message, wParam, lParam);
}
Example #20
0
FORUM3DVIEW_EXPORT BOOL __stdcall SCForumMdl3DDraw( HDC hDC, const RECT * r, LPCTSTR sFileName, LPCTSTR sWorkDir, int nDrawFlags, HANDLE hStopEvent )
{
	S3DBox			Box;
	SParallelView			View;
	CRotator		Rot;
	CRect			Region(r);

	TCHAR Path[MAXPATH];
	_tcscpy_s(Path, sFileName);
	PathRemoveFileSpec(Path);
	CThumbCashe cashe(Path);
	SThumbParam param;
	param.nWidth = WORD(r->right-r->left);
	param.nHeight = WORD(r->bottom-r->top);
	param.eType = ThumbProjection;
	if (cashe.Get(PathFindFileName(sFileName), param, hDC))
		return TRUE;
	
	if (_tcsicmp(PathFindExtension(sFileName),_T(".mp4"))==0)
	{
		return FALSE;
	}
	CForumViewGeometry fvg(nullptr,nullptr);
	fvg.m_bForThumbs = true;
	fvg.m_bDeleteInnerPlates = false;
	if(!fvg.LoadFromFile(sFileName, 0, 0, false))
		return FALSE;
	//fvg.ClearCashe();
	fvg.DrawOptionsChanged(nullptr, true); // Show only used nodes
	Rot.SetPredefinedView(ThumbProjection);
	fvg.Get3DBox(&Rot, &Box);
	View.GeometryZoomAll(&Region, 5, &Box);

	Graphics::TColor	cOld = TColor(0);
	HPEN				hPen, hPenOld;

	hPen = CreatePen(PS_SOLID, 0, cOld);
	hPenOld = HPEN(SelectObject(hDC, hPen));

	int cx = (Region.left + Region.right) / 2, cy = (Region.top + Region.bottom) / 2;
	size_t NumElements = fvg.ElementArray.size();
	for(size_t i = 0; i < NumElements /*&& !Terminated*/; i++)
	{
		//int Percent = (k) * 100.0 / nFiles + (i + 1) * 100.0 / (2 * nFiles * NumElements);

		if (::WaitForSingleObject(hStopEvent,0) == WAIT_OBJECT_0)
		{
			::SetEvent(hStopEvent);
			SelectObject(hDC, hPenOld);
			DeleteObject(hPen);
			return FALSE;
		}
		CViewElement		El = fvg.ElementArray[i];
		Graphics::TColor	c = El.Color;

		if(c != cOld)
		{
			SelectObject(hDC, hPenOld);
			DeleteObject(hPen);
			hPen = CreatePen(PS_SOLID, 0, c);
			hPenOld = HPEN(SelectObject(hDC, hPen));
		}

		int				NumPoints = El.NumVertexs();
		if (!El.bContoured)
			continue;
		NODE_NUM_TYPE pn0 = El.Points[0];
		S3dPoint		p1 = S3dPoint(fvg.VertexArray[pn0]);
		Rot.Rotate(p1.x, p1.y, p1.z);
		MoveToEx(hDC, TO_SCR_X(p1.x), TO_SCR_Y(p1.y), nullptr);
		for(int j = 1; j < NumPoints; j++)
		{
			NODE_NUM_TYPE	pn = El.Points[j];
			S3dPoint		p = S3dPoint(fvg.VertexArray[pn]);
			Rot.Rotate(p.x, p.y, p.z);
//			if(!fvg.WasDrawed(pn1, pn))
				LineTo(hDC, TO_SCR_X(p.x), TO_SCR_Y(p.y));
/*
			else
				MoveToEx(hDC, TO_SCR_X(p.x), TO_SCR_Y(p.y), NULL);
*/
		}

//		if(!fvg.WasDrawed(pn0, pn1))
			LineTo(hDC, TO_SCR_X(p1.x), TO_SCR_Y(p1.y));
	}

	SelectObject(hDC, hPenOld);
	DeleteObject(hPen);
	cashe.Put(PathFindFileName(sFileName), param, hDC);
	
	return TRUE;
}
Example #21
0
//

#include "stdafx.h"
#include "WinApi-Right.h"
#include "Snake.h"
#include <time.h>

#define MAX_LOADSTRING 100
#define TIMER 1

// Global Variables:
HINSTANCE hInst;								// current instance
TCHAR szTitle[MAX_LOADSTRING];					// The title bar text
TCHAR szWindowClass[MAX_LOADSTRING];			// the main window class name
vector<Snake*> snakes;
HPEN hPen = CreatePen(PS_SOLID, 20, RGB(0, 0, 0));	//pióro o gruboœci 20 mm
HPEN hRedPen = CreatePen(PS_SOLID, 20, RGB(255, 0, 0));	//pióro o gruboœci 20 mm
Berry *berry;

// Forward declarations of functions included in this code module:
ATOM				MyRegisterClass(HINSTANCE hInstance);
BOOL				InitInstance(HINSTANCE, int);
LRESULT CALLBACK	WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK	About(HWND, UINT, WPARAM, LPARAM);

int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
	UNREFERENCED_PARAMETER(hPrevInstance);
Example #22
0
void wxBitmapButton::DrawFace( WXHDC dc, int left, int top,
    int right, int bottom, bool sel )
{
    HPEN oldp;
    HPEN penBorder;
    HPEN penLight;
    HPEN penShadow;
    HBRUSH brushFace;

    // create needed pens and brush
    penBorder = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_WINDOWFRAME));
    penShadow = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_BTNSHADOW));
    penLight  = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_BTNHIGHLIGHT));
    brushFace = CreateSolidBrush(COLOR_BTNFACE);

    // draw the rectangle
    RECT rect;
    rect.left   = left;
    rect.right  = right;
    rect.top    = top;
    rect.bottom = bottom;
    FillRect((HDC) dc, &rect, brushFace);

    // draw the border
    oldp = (HPEN) SelectObject( (HDC) dc, penBorder);
    MoveToEx((HDC) dc,left+1,top,NULL);LineTo((HDC) dc,right-1,top);
    MoveToEx((HDC) dc,left,top+1,NULL);LineTo((HDC) dc,left,bottom-1);
    MoveToEx((HDC) dc,left+1,bottom-1,NULL);LineTo((HDC) dc,right-1,bottom-1);
    MoveToEx((HDC) dc,right-1,top+1,NULL);LineTo((HDC) dc,right-1,bottom-1);

    SelectObject( (HDC) dc, penShadow);
    if (sel)
    {
        MoveToEx((HDC) dc,left+1    ,bottom-2   ,NULL);
        LineTo((HDC) dc,  left+1    ,top+1);
        LineTo((HDC) dc,  right-2   ,top+1);
    }
    else
    {
        MoveToEx((HDC) dc,left+1    ,bottom-2   ,NULL);
        LineTo((HDC) dc,  right-2   ,bottom-2);
        LineTo((HDC) dc,  right-2   ,top);

        MoveToEx((HDC) dc,left+2    ,bottom-3   ,NULL);
        LineTo((HDC) dc,  right-3   ,bottom-3);
        LineTo((HDC) dc,  right-3   ,top+1);

        SelectObject( (HDC) dc, penLight);

        MoveToEx((HDC) dc,left+1    ,bottom-2   ,NULL);
        LineTo((HDC) dc,  left+1    ,top+1);
        LineTo((HDC) dc,  right-2   ,top+1);
    }

    // delete allocated resources
    SelectObject((HDC) dc,oldp);
    DeleteObject(penBorder);
    DeleteObject(penLight);
    DeleteObject(penShadow);
    DeleteObject(brushFace);
}
Example #23
0
File: gdiobj.c Project: iXit/wine
static void test_GetCurrentObject(void)
{
    DWORD type;
    HPEN hpen;
    HBRUSH hbrush;
    HPALETTE hpal;
    HFONT hfont;
    HBITMAP hbmp;
    HRGN hrgn;
    HDC hdc;
    HCOLORSPACE hcs;
    HGDIOBJ hobj;
    LOGBRUSH lb;
    LOGCOLORSPACEA lcs;

    hdc = CreateCompatibleDC(0);
    assert(hdc != 0);

    type = GetObjectType(hdc);
    ok(type == OBJ_MEMDC, "GetObjectType returned %u\n", type);

    hpen = CreatePen(PS_SOLID, 10, RGB(10, 20, 30));
    assert(hpen != 0);
    SelectObject(hdc, hpen);
    hobj = GetCurrentObject(hdc, OBJ_PEN);
    ok(hobj == hpen, "OBJ_PEN is wrong: %p\n", hobj);
    hobj = GetCurrentObject(hdc, OBJ_EXTPEN);
    ok(hobj == hpen, "OBJ_EXTPEN is wrong: %p\n", hobj);

    hbrush = CreateSolidBrush(RGB(10, 20, 30));
    assert(hbrush != 0);
    SelectObject(hdc, hbrush);
    hobj = GetCurrentObject(hdc, OBJ_BRUSH);
    ok(hobj == hbrush, "OBJ_BRUSH is wrong: %p\n", hobj);

    hpal = CreateHalftonePalette(hdc);
    assert(hpal != 0);
    SelectPalette(hdc, hpal, FALSE);
    hobj = GetCurrentObject(hdc, OBJ_PAL);
    ok(hobj == hpal, "OBJ_PAL is wrong: %p\n", hobj);

    hfont = CreateFontA(10, 5, 0, 0, FW_DONTCARE, 0, 0, 0, ANSI_CHARSET,
                        OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
                        DEFAULT_PITCH, "MS Sans Serif");
    assert(hfont != 0);
    SelectObject(hdc, hfont);
    hobj = GetCurrentObject(hdc, OBJ_FONT);
    ok(hobj == hfont, "OBJ_FONT is wrong: %p\n", hobj);

    hbmp = CreateBitmap(100, 100, 1, 1, NULL);
    assert(hbmp != 0);
    SelectObject(hdc, hbmp);
    hobj = GetCurrentObject(hdc, OBJ_BITMAP);
    ok(hobj == hbmp, "OBJ_BITMAP is wrong: %p\n", hobj);

    assert(GetObjectA(hbrush, sizeof(lb), &lb) == sizeof(lb));
    hpen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_SQUARE | PS_JOIN_BEVEL,
                        10, &lb, 0, NULL);
    assert(hpen != 0);
    SelectObject(hdc, hpen);
    hobj = GetCurrentObject(hdc, OBJ_PEN);
    ok(hobj == hpen, "OBJ_PEN is wrong: %p\n", hobj);
    hobj = GetCurrentObject(hdc, OBJ_EXTPEN);
    ok(hobj == hpen, "OBJ_EXTPEN is wrong: %p\n", hobj);

    hcs = GetColorSpace(hdc);
    if (hcs)
    {
        trace("current color space is not NULL\n");
        ok(GetLogColorSpaceA(hcs, &lcs, sizeof(lcs)), "GetLogColorSpace failed\n");
        hcs = CreateColorSpaceA(&lcs);
        ok(hcs != 0, "CreateColorSpace failed\n");
        SelectObject(hdc, hcs);
        hobj = GetCurrentObject(hdc, OBJ_COLORSPACE);
        ok(hobj == hcs, "OBJ_COLORSPACE is wrong: %p\n", hobj);
    }

    hrgn = CreateRectRgn(1, 1, 100, 100);
    assert(hrgn != 0);
    SelectObject(hdc, hrgn);
    hobj = GetCurrentObject(hdc, OBJ_REGION);
    ok(!hobj, "OBJ_REGION is wrong: %p\n", hobj);

    DeleteDC(hdc);
}
Example #24
0
	/**
	 * @brief   Draw a line.
	 * @note    Optional - The high level driver can emulate using software.
	 *
	 * @param[in] x0, y0   The start of the line
	 * @param[in] x1, y1   The end of the line
	 * @param[in] color    The color of the line
	 *
	 * @notapi
	 */
	void lld_gdisp_draw_line(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) {
		POINT p;
		HPEN pen;
		HDC dc;
		HGDIOBJ old;
		#if GDISP_NEED_CLIP
			HRGN	clip;
		#endif
		#if WIN32_USE_MSG_REDRAW
			RECT	rect;
		#endif
		#if GDISP_NEED_CONTROL
			coord_t	t;
		#endif

		#if GDISP_NEED_CLIP
			clip = NULL;
		#endif

		#if GDISP_NEED_CONTROL
			switch(GDISP.Orientation) {
			case GDISP_ROTATE_0:
				#if GDISP_NEED_CLIP
					// Clip post orientation change
					if (GDISP.clipx0 != 0 || GDISP.clipy0 != 0 || GDISP.clipx1 != GDISP.Width || GDISP.clipy1 != GDISP.Height)
						clip = CreateRectRgn(GDISP.clipx0, GDISP.clipy0, GDISP.clipx1, GDISP.clipy1);
				#endif
				break;
			case GDISP_ROTATE_90:
				t = GDISP.Height - 1 - y0;
				y0 = x0;
				x0 = t;
				t = GDISP.Height - 1 - y1;
				y1 = x1;
				x1 = t;
				#if GDISP_NEED_CLIP
					// Clip post orientation change
					if (GDISP.clipx0 != 0 || GDISP.clipy0 != 0 || GDISP.clipx1 != GDISP.Width || GDISP.clipy1 != GDISP.Height)
						clip = CreateRectRgn(GDISP.Height-1-GDISP.clipy1, GDISP.clipx0, GDISP.Height-1-GDISP.clipy0, GDISP.clipx1);
				#endif
				break;
			case GDISP_ROTATE_180:
				x0 = GDISP.Width - 1 - x0;
				y0 = GDISP.Height - 1 - y0;
				x1 = GDISP.Width - 1 - x1;
				y1 = GDISP.Height - 1 - y1;
				#if GDISP_NEED_CLIP
					// Clip post orientation change
					if (GDISP.clipx0 != 0 || GDISP.clipy0 != 0 || GDISP.clipx1 != GDISP.Width || GDISP.clipy1 != GDISP.Height)
						clip = CreateRectRgn(GDISP.Width-1-GDISP.clipx1, GDISP.Height-1-GDISP.clipy1, GDISP.Width-1-GDISP.clipx0, GDISP.Height-1-GDISP.clipy0);
				#endif
				break;
			case GDISP_ROTATE_270:
				t = GDISP.Width - 1 - x0;
				x0 = y0;
				y0 = t;
				t = GDISP.Width - 1 - x1;
				x1 = y1;
				y1 = t;
				#if GDISP_NEED_CLIP
					// Clip post orientation change
					if (GDISP.clipx0 != 0 || GDISP.clipy0 != 0 || GDISP.clipx1 != GDISP.Width || GDISP.clipy1 != GDISP.Height)
						clip = CreateRectRgn(GDISP.clipy0, GDISP.Width-1-GDISP.clipx1, GDISP.clipy1, GDISP.Width-1-GDISP.clipx0);
				#endif
				break;
			}
		#else
			#if GDISP_NEED_CLIP
				clip = NULL;
				if (GDISP.clipx0 != 0 || GDISP.clipy0 != 0 || GDISP.clipx1 != GDISP.Width || GDISP.clipy1 != GDISP.Height)
					clip = CreateRectRgn(GDISP.clipx0, GDISP.clipy0, GDISP.clipx1, GDISP.clipy1);
			#endif
		#endif
	
		color = COLOR2BGR(color);
		pen = CreatePen(PS_SOLID, 1, color);
		if (pen) {
			// Draw the line in the buffer
			#if GDISP_NEED_CLIP
				if (clip) SelectClipRgn(dcBuffer, clip);
			#endif
			old = SelectObject(dcBuffer, pen);
			MoveToEx(dcBuffer, x0, y0, &p);
			LineTo(dcBuffer, x1, y1);
			SelectObject(dcBuffer, old);
			SetPixel(dcBuffer, x1, y1, color);
			#if GDISP_NEED_CLIP
				if (clip) SelectClipRgn(dcBuffer, NULL);
			#endif

			#if WIN32_USE_MSG_REDRAW
				rect.left = x0; rect.right = x1+1;
				rect.top = y0; rect.bottom = y1+1;
				InvalidateRect(winRootWindow, &rect, FALSE);
				UpdateWindow(winRootWindow);
			#else
				// Redrawing the line on the screen is cheaper than invalidating the whole rectangular area
				dc = GetDC(winRootWindow);
				#if GDISP_NEED_CLIP
					if (clip) SelectClipRgn(dc, clip);
				#endif
				old = SelectObject(dc, pen);
				MoveToEx(dc, x0, y0, &p);
				LineTo(dc, x1, y1);
				SelectObject(dc, old);
				SetPixel(dc, x1, y1, color);
				#if GDISP_NEED_CLIP
					if (clip) SelectClipRgn(dc, NULL);
				#endif
				ReleaseDC(winRootWindow, dc);
			#endif

			DeleteObject(pen);
		}
	}
Example #25
0
LRESULT CALLBACK
SettingsWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
        case WM_VSCROLL:
            zoomTo(125 << SendMessage(hTrackbarZoom, TBM_GETPOS, 0, 0), 0, 0);
            break;
        case WM_PAINT:
        {
            HDC hdc = GetDC(hwnd);
            RECT rect1 = { 0, 0, 42, 66 };
            RECT rect2 = { 0, 70, 42, 136 };

            DefWindowProc(hwnd, message, wParam, lParam);

            DrawEdge(hdc, &rect1, BDR_SUNKENOUTER, (activeTool == TOOL_ZOOM) ? BF_RECT : BF_RECT | BF_MIDDLE);
            DrawEdge(hdc, &rect2, (activeTool >= TOOL_RECT) ? BDR_SUNKENOUTER : 0, BF_RECT | BF_MIDDLE);
            switch (activeTool)
            {
                case TOOL_FREESEL:
                case TOOL_RECTSEL:
                case TOOL_TEXT:
                {
                    HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
                    SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
                    Rectangle(hdc, 2, transpBg * 31 + 2, 41, transpBg * 31 + 33);
                    DeleteObject(SelectObject(hdc, oldPen));
                    DrawIconEx(hdc, 1, 2, hNontranspIcon, 40, 30, 0, NULL, DI_NORMAL);
                    DrawIconEx(hdc, 1, 33, hTranspIcon, 40, 30, 0, NULL, DI_NORMAL);
                    break;
                }
                case TOOL_RUBBER:
                {
                    int i;
                    HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
                    for(i = 0; i < 4; i++)
                    {
                        if (rubberRadius == i + 2)
                        {
                            SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
                            Rectangle(hdc, 14, i * 15 + 2, 29, i * 15 + 17);
                            SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHTTEXT));
                        }
                        else
                            SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT));
                        Rectangle(hdc, 19 - i, i * 14 + 7, 24 + i, i * 16 + 12);
                    }
                    DeleteObject(SelectObject(hdc, oldPen));
                    break;
                }
                case TOOL_BRUSH:
                {
                    int i;
                    HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
                    SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
                    Rectangle(hdc, brushStyle % 3 * 13 + 2, brushStyle / 3 * 15 + 2, brushStyle % 3 * 13 + 15,
                              brushStyle / 3 * 15 + 17);
                    DeleteObject(SelectObject(hdc, oldPen));
                    for(i = 0; i < 12; i++)
                        Brush(hdc, i % 3 * 13 + 7, i / 3 * 15 + 8, i % 3 * 13 + 7, i / 3 * 15 + 8,
                              GetSysColor((i == brushStyle) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), i);
                    break;
                }
                case TOOL_AIRBRUSH:
                {
                    HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
                    SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
                    switch (airBrushWidth)
                    {
                        case 5:
                            Rectangle(hdc, 2, 2, 21, 31);
                            break;
                        case 8:
                            Rectangle(hdc, 20, 2, 41, 31);
                            break;
                        case 3:
                            Rectangle(hdc, 2, 30, 16, 61);
                            break;
                        case 12:
                            Rectangle(hdc, 15, 30, 41, 61);
                            break;
                    }
                    Airbrush(hdc, 10, 15,
                             GetSysColor((airBrushWidth == 5) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 5);
                    Airbrush(hdc, 30, 15,
                             GetSysColor((airBrushWidth == 8) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 8);
                    Airbrush(hdc, 8, 45,
                             GetSysColor((airBrushWidth == 3) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 3);
                    Airbrush(hdc, 27, 45,
                             GetSysColor((airBrushWidth == 12) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 12);
                    DeleteObject(SelectObject(hdc, oldPen));
                    break;
                }
                case TOOL_LINE:
                case TOOL_BEZIER:
                {
                    int i;
                    HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
                    for(i = 0; i < 5; i++)
                    {
                        if (lineWidth == i + 1)
                        {
                            SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
                            Rectangle(hdc, 2, i * 12 + 2, 41, i * 12 + 14);
                            SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHTTEXT));
                        }
                        else
                            SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT));
                        Rectangle(hdc, 5, i * 12 + 6, 38, i * 12 + 8 + i);
                    }
                    DeleteObject(SelectObject(hdc, oldPen));
                    break;
                }
                case TOOL_RECT:
                case TOOL_SHAPE:
                case TOOL_ELLIPSE:
                case TOOL_RRECT:
                {
                    int i;
                    HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
                    for(i = 0; i < 3; i++)
                    {
                        if (shapeStyle == i)
                        {
                            SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
                            Rectangle(hdc, 2, i * 20 + 2, 41, i * 20 + 22);
                        }
                    }
                    Rect(hdc, 5, 6, 37, 16,
                         GetSysColor((shapeStyle == 0) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT),
                         GetSysColor(COLOR_APPWORKSPACE), 1, 0);
                    Rect(hdc, 5, 26, 37, 36,
                         GetSysColor((shapeStyle == 1) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT),
                         GetSysColor(COLOR_APPWORKSPACE), 1, 1);
                    Rect(hdc, 5, 46, 37, 56, GetSysColor(COLOR_APPWORKSPACE), GetSysColor(COLOR_APPWORKSPACE),
                         1, 1);
                    for(i = 0; i < 5; i++)
                    {
                        if (lineWidth == i + 1)
                        {
                            SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
                            Rectangle(hdc, 2, i * 12 + 72, 41, i * 12 + 84);
                            SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHTTEXT));
                        }
                        else
                            SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT));
                        Rectangle(hdc, 5, i * 12 + 76, 38, i * 12 + 78 + i);
                    }
                    DeleteObject(SelectObject(hdc, oldPen));
                    break;
                }
            }
            ReleaseDC(hwnd, hdc);
            break;
        }
        case WM_LBUTTONDOWN:
        {
            int x = GET_X_LPARAM(lParam);
            int y = GET_Y_LPARAM(lParam);
            switch (activeTool)
            {
                case TOOL_FREESEL:
                case TOOL_RECTSEL:
                case TOOL_TEXT:
                    if ((y > 1) && (y < 64))
                    {
                        transpBg = (y - 2) / 31;
                        InvalidateRect(hwnd, NULL, TRUE);

                        ForceRefreshSelectionContents();
                    }
                    break;
                case TOOL_RUBBER:
                    if ((y > 1) && (y < 62))
                    {
                        rubberRadius = (y - 2) / 15 + 2;
                        InvalidateRect(hwnd, NULL, TRUE);
                    }
                    break;
                case TOOL_BRUSH:
                    if ((x > 1) && (x < 40) && (y > 1)
                        && (y < 62))
                    {
                        brushStyle = (y - 2) / 15 * 3 + (x - 2) / 13;
                        InvalidateRect(hwnd, NULL, TRUE);
                    }
                    break;
                case TOOL_AIRBRUSH:
                    if (y < 62)
                    {
                        if (y < 30)
                        {
                            if (x < 20)
                                airBrushWidth = 5;
                            else
                                airBrushWidth = 8;
                        }
                        else
                        {
                            if (x < 15)
                                airBrushWidth = 3;
                            else
                                airBrushWidth = 12;
                        }
                        InvalidateRect(hwnd, NULL, TRUE);
                    }
                    break;
                case TOOL_LINE:
                case TOOL_BEZIER:
                    if (y <= 62)
                    {
                        lineWidth = (y - 2) / 12 + 1;
                        InvalidateRect(hwnd, NULL, TRUE);
                    }
                    break;
                case TOOL_RECT:
                case TOOL_SHAPE:
                case TOOL_ELLIPSE:
                case TOOL_RRECT:
                    if (y <= 60)
                    {
                        shapeStyle = (y - 2) / 20;
                        InvalidateRect(hwnd, NULL, TRUE);
                    }
                    if ((y >= 70) && (y <= 132))
                    {
                        lineWidth = (y - 72) / 12 + 1;
                        InvalidateRect(hwnd, NULL, TRUE);
                    }
                    break;
            }
            break;
        }

        default:
            return DefWindowProc(hwnd, message, wParam, lParam);
    }

    return 0;
}
Example #26
0
static LRESULT myWindowProc(HWND hWnd,	UINT Msg, WPARAM wParam, LPARAM lParam)
{
	HDC			dc;
	PAINTSTRUCT	ps;
	#if GINPUT_NEED_TOGGLE
		HBRUSH		hbrOn, hbrOff;
		HPEN		pen;
		RECT		rect;
		HGDIOBJ		old;
		POINT 		p;
		coord_t		pos;
		uint8_t		bit;
	#endif

	switch (Msg) {
	case WM_CREATE:
		break;
	case WM_LBUTTONDOWN:
		#if GINPUT_NEED_MOUSE
			if ((coord_t)HIWORD(lParam) < wHeight) {
				mousebuttons |= GINPUT_MOUSE_BTN_LEFT;
				goto mousemove;
			}
		#endif
		#if GINPUT_NEED_TOGGLE
			bit = 1 << ((coord_t)LOWORD(lParam)*8/wWidth);
			toggles ^= bit;
			rect.left = 0;
			rect.right = wWidth;
			rect.top = wHeight;
			rect.bottom = wHeight + WIN32_BUTTON_AREA;
			InvalidateRect(hWnd, &rect, FALSE);
			UpdateWindow(hWnd);
			#if GINPUT_TOGGLE_POLL_PERIOD == TIME_INFINITE
				ginputToggleWakeup();
			#endif
		#endif
		break;
	case WM_LBUTTONUP:
		#if GINPUT_NEED_TOGGLE
			if ((toggles & 0xF0)) {
				toggles &= 0x0F;
				rect.left = 0;
				rect.right = wWidth;
				rect.top = wHeight;
				rect.bottom = wHeight + WIN32_BUTTON_AREA;
				InvalidateRect(hWnd, &rect, FALSE);
				UpdateWindow(hWnd);
				#if GINPUT_TOGGLE_POLL_PERIOD == TIME_INFINITE
					ginputToggleWakeup();
				#endif
			}
		#endif
		#if GINPUT_NEED_MOUSE
			if ((coord_t)HIWORD(lParam) < wHeight) {
				mousebuttons &= ~GINPUT_MOUSE_BTN_LEFT;
				goto mousemove;
			}
		#endif
		break;
#if GINPUT_NEED_MOUSE
	case WM_MBUTTONDOWN:
		if ((coord_t)HIWORD(lParam) < wHeight) {
			mousebuttons |= GINPUT_MOUSE_BTN_MIDDLE;
			goto mousemove;
		}
		break;
	case WM_MBUTTONUP:
		if ((coord_t)HIWORD(lParam) < wHeight) {
			mousebuttons &= ~GINPUT_MOUSE_BTN_MIDDLE;
			goto mousemove;
		}
		break;
	case WM_RBUTTONDOWN:
		if ((coord_t)HIWORD(lParam) < wHeight) {
			mousebuttons |= GINPUT_MOUSE_BTN_RIGHT;
			goto mousemove;
		}
		break;
	case WM_RBUTTONUP:
		if ((coord_t)HIWORD(lParam) < wHeight) {
			mousebuttons &= ~GINPUT_MOUSE_BTN_RIGHT;
			goto mousemove;
		}
		break;
	case WM_MOUSEMOVE:
		if ((coord_t)HIWORD(lParam) >= wHeight)
			break;
	mousemove:
		mousex = (coord_t)LOWORD(lParam); 
		mousey = (coord_t)HIWORD(lParam); 
		#if GINPUT_MOUSE_POLL_PERIOD == TIME_INFINITE
			ginputMouseWakeup();
		#endif
		break;
#endif
	case WM_SYSKEYDOWN:
	case WM_KEYDOWN:
	case WM_SYSKEYUP:
	case WM_KEYUP:
		break;
	case WM_CHAR:
	case WM_DEADCHAR:
	case WM_SYSCHAR:
	case WM_SYSDEADCHAR:
		break;
	case WM_PAINT:
		dc = BeginPaint(hWnd, &ps);
		BitBlt(dc, ps.rcPaint.left, ps.rcPaint.top,
			ps.rcPaint.right - ps.rcPaint.left,
			(ps.rcPaint.bottom > wHeight ? wHeight : ps.rcPaint.bottom) - ps.rcPaint.top,
			dcBuffer, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY);
		#if GINPUT_NEED_TOGGLE
			if (ps.rcPaint.bottom >= wHeight) {
				pen = CreatePen(PS_SOLID, 1, COLOR2BGR(Black));
				hbrOn = CreateSolidBrush(COLOR2BGR(Blue));
				hbrOff = CreateSolidBrush(COLOR2BGR(Gray));
				old = SelectObject(dc, pen);
				MoveToEx(dc, 0, wHeight, &p);
				LineTo(dc, wWidth, wHeight);
				for(pos = 0, bit=1; pos < wWidth; pos=rect.right, bit <<= 1) {
					rect.left = pos;
					rect.right = pos + wWidth/8;
					rect.top = wHeight;
					rect.bottom = wHeight + WIN32_BUTTON_AREA;
					FillRect(dc, &rect, (toggles & bit) ? hbrOn : hbrOff);
					if (pos > 0) {
						MoveToEx(dc, rect.left, rect.top, &p);
						LineTo(dc, rect.left, rect.bottom);
					}
				}
				DeleteObject(hbrOn);
				DeleteObject(hbrOff);
				SelectObject(dc, old);
			}
		#endif
		EndPaint(hWnd, &ps);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		SelectObject(dcBuffer, dcOldBitmap);
		DeleteDC(dcBuffer);
		DeleteObject(dcBitmap);
		winRootWindow = NULL;
		break;
	default:
		return DefWindowProc(hWnd, Msg, wParam, lParam);
	}
	return 0;
}
Example #27
0
static LRESULT WINAPI submenuWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  const int itemheight = 12, lcol=12, rcol=12, mcol=10;
  switch (uMsg)
  {
    case WM_CREATE:
      m_trackingMenus.Add(hwnd);
      SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam);

      if (m_trackingPar && !(m_trackingFlags&TPM_NONOTIFY))
        SendMessage(m_trackingPar,WM_INITMENUPOPUP,(WPARAM)lParam,0);

      {
        HDC hdc = GetDC(hwnd);
        HMENU__ *menu = (HMENU__*)lParam;
        int ht = menu->items.GetSize()*itemheight, wid=100,wid2=0;
        int xpos=m_trackingPt.x;
        int ypos=m_trackingPt.y;
        int x;
        for (x=0; x < menu->items.GetSize(); x++)
        {
          MENUITEMINFO *inf = menu->items.Get(x);
          if (inf->fType == MFT_STRING && inf->dwTypeData)
          {
            RECT r={0,};
            const char *pt2 = strstr(inf->dwTypeData,"\t");
            DrawText(hdc,inf->dwTypeData,pt2 ? pt2-inf->dwTypeData : -1,&r,DT_CALCRECT|DT_SINGLELINE);
            if (r.right > wid) wid=r.right;
            if (pt2)
            { 
              r.right=r.left;
              DrawText(hdc,pt2+1,-1,&r,DT_CALCRECT|DT_SINGLELINE);
              if (r.right > wid2) wid2=r.right;
            }
          }
        }
        wid+=lcol+rcol + (wid2?wid2+mcol:0);
        ReleaseDC(hwnd,hdc);
        RECT tr={xpos,ypos,xpos+wid,ypos+ht},vp;
        SWELL_GetViewPort(&vp,&tr,true);
        if (tr.bottom > vp.bottom) { tr.top += vp.bottom-tr.bottom; tr.bottom=vp.bottom; }
        if (tr.right > vp.right) { tr.left += vp.right-tr.right; tr.right=vp.right; }
        if (tr.left < vp.left) { tr.right += vp.left-tr.left; tr.left=vp.left; }
        if (tr.top < vp.top) { tr.bottom += vp.top-tr.top; tr.top=vp.top; }
        SetWindowPos(hwnd,NULL,tr.left,tr.top,tr.right-tr.left,tr.bottom-tr.top,SWP_NOZORDER);
      }
      SetWindowLong(hwnd,GWL_STYLE,GetWindowLong(hwnd,GWL_STYLE)&~WS_CAPTION);
      ShowWindow(hwnd,SW_SHOW);
      SetFocus(hwnd);
      SetTimer(hwnd,1,250,NULL);
    break;
    case WM_PAINT:
      {
        PAINTSTRUCT ps;
        if (BeginPaint(hwnd,&ps))
        {
          RECT cr;
          GetClientRect(hwnd,&cr);
          HBRUSH br=CreateSolidBrush(GetSysColor(COLOR_3DFACE));
          HPEN pen=CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DSHADOW));
          HGDIOBJ oldbr = SelectObject(ps.hdc,br);
          HGDIOBJ oldpen = SelectObject(ps.hdc,pen);
          Rectangle(ps.hdc,cr.left,cr.top,cr.right-1,cr.bottom-1);
          SetBkMode(ps.hdc,TRANSPARENT);
          int cols[2]={ GetSysColor(COLOR_BTNTEXT),GetSysColor(COLOR_3DHILIGHT)};
          HMENU__ *menu = (HMENU__*)GetWindowLongPtr(hwnd,GWLP_USERDATA);
          int x;
          for (x=0; x < menu->items.GetSize(); x++)
          {
            MENUITEMINFO *inf = menu->items.Get(x);
            RECT r={lcol,x*itemheight,cr.right,(x+1)*itemheight};
            bool dis = !!(inf->fState & MF_GRAYED);
            SetTextColor(ps.hdc,cols[dis]);
            if (inf->fType == MFT_STRING && inf->dwTypeData)
            {
              const char *pt2 = strstr(inf->dwTypeData,"\t");
              DrawText(ps.hdc,inf->dwTypeData,pt2 ? pt2-inf->dwTypeData : -1,&r,DT_VCENTER|DT_SINGLELINE);
              if (pt2)
              {
                RECT tr=r; tr.right-=rcol;
                DrawText(ps.hdc,pt2+1,-1,&tr,DT_VCENTER|DT_SINGLELINE|DT_RIGHT);
              }
            }
            else 
            {
              MoveToEx(ps.hdc,r.left - lcol/2,(r.top+r.bottom)/2,NULL);
              LineTo(ps.hdc,r.right - rcol*3/2,(r.top+r.bottom)/2);
            }
            if (inf->hSubMenu) 
            {
               RECT r2=r; r2.left = r2.right - rcol;
               DrawText(ps.hdc,">",-1,&r2,DT_VCENTER|DT_RIGHT|DT_SINGLELINE);
            }
            if (inf->fState&MF_CHECKED)
            {
               RECT r2=r; r2.left = 0; r2.right=lcol;
               DrawText(ps.hdc,"X",-1,&r2,DT_VCENTER|DT_CENTER|DT_SINGLELINE);
            }
          }
          SelectObject(ps.hdc,oldbr);
          SelectObject(ps.hdc,oldpen);
          DeleteObject(br);
          DeleteObject(pen);
          EndPaint(hwnd,&ps); 
        }       
      }
    break;
    case WM_TIMER:
      if (wParam==1)
      {
        HWND GetFocusIncludeMenus();
        HWND h = GetFocusIncludeMenus();
        if (h!=hwnd)
        {
          int a = h ? m_trackingMenus.Find(h) : -1;
          if (a<0 || a < m_trackingMenus.Find(hwnd)) DestroyWindow(hwnd); 
        }
      }
    break;
    case WM_DESTROY:
      {
        int a = m_trackingMenus.Find(hwnd);
        m_trackingMenus.Delete(a);
        if (m_trackingMenus.Get(a)) DestroyWindow(m_trackingMenus.Get(a));
        RemoveProp(hwnd,"SWELL_MenuOwner");
      }
    break;
    case WM_LBUTTONUP:
    case WM_RBUTTONUP:
      {
        RECT r;
        GetClientRect(hwnd,&r);
        if (GET_X_LPARAM(lParam)>=r.left && GET_X_LPARAM(lParam)<r.right)
        {
          int which = GET_Y_LPARAM(lParam)/itemheight;
          HMENU__ *menu = (HMENU__*)GetWindowLongPtr(hwnd,GWLP_USERDATA);
          MENUITEMINFO *inf = menu->items.Get(which);
          if (inf) 
          {
            if (inf->fState&MF_GRAYED){ }
            else if (inf->hSubMenu)
            {
              int a = m_trackingMenus.Find(hwnd);
              HWND next = m_trackingMenus.Get(a+1);
              if (next) DestroyWindow(next); 

              m_trackingPt.x=r.right;
              m_trackingPt.y=r.top + which*itemheight;
              ClientToScreen(hwnd,&m_trackingPt);
              HWND hh;
              submenuWndProc(hh=new HWND__(NULL,0,NULL,"menu",false,submenuWndProc,NULL),WM_CREATE,0,(LPARAM)inf->hSubMenu);
              SetProp(hh,"SWELL_MenuOwner",GetProp(hh,"SWELL_MenuOwner"));
            }
            else if (inf->wID) m_trackingRet = inf->wID;
          }
          else DestroyWindow(hwnd);
        }
        else DestroyWindow(hwnd);
      }
    break;
  }
  return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
Example #28
0
static void BoxPreview_OnPaint(HWND hwnd, HDC mydc, int mode)
{
	RECT rc;

	switch (mode) {
	case 0:
		{ //  Avatar
			HDC hdcAvatar = CreateCompatibleDC(mydc);
			HBITMAP hbmSave = (HBITMAP)SelectObject(hdcAvatar, hbmNoAvatar);
			GetClientRect(hwnd, &rc);
			BITMAP bmp;
			GetObject(hbmNoAvatar, sizeof(bmp), &bmp);
			StretchBlt(mydc, 0, 0, rc.right, rc.bottom, hdcAvatar, 0, 0, abs(bmp.bmWidth), abs(bmp.bmHeight), SRCCOPY);
			SelectObject(hdcAvatar, hbmSave);
			DeleteDC(hdcAvatar);
			HRGN rgn = CreateRoundRectRgn(0, 0, rc.right, rc.bottom, 2 * PopupOptions.avatarRadius, 2 * PopupOptions.avatarRadius);
			FrameRgn(mydc, rgn, (HBRUSH)GetStockObject(BLACK_BRUSH), 1, 1);
			DeleteObject(rgn);
		}
		break;

	case 1:
		{ //  Opacity
			HBRUSH hbr = CreateSolidBrush(fonts.clBack);
			HFONT hfnt = (HFONT)SelectObject(mydc, fonts.title);
			GetClientRect(hwnd, &rc);
			FillRect(mydc, &rc, hbr);
			DrawIconEx(mydc, 10, (rc.bottom - rc.top - 16) / 2, LoadIconEx(IDI_POPUP), 16, 16, 0, hbr, DI_NORMAL);
			SetBkMode(mydc, TRANSPARENT);
			GetClientRect(hwnd, &rc);
			rc.left += 30; //  10+16+4 -- icon
			rc.right -= (rc.right - rc.left) / 3;
			rc.bottom -= (rc.bottom - rc.top) / 3;
			DrawText(mydc, _T(MODULNAME_LONG), -1, &rc, DT_CENTER | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER);
			GetClientRect(hwnd, &rc);
			rc.left += 30; //  10+16+4 -- icon
			rc.left += (rc.right - rc.left) / 3;
			rc.top += (rc.bottom - rc.top) / 3;
			DrawText(mydc, _T(MODULNAME_LONG), -1, &rc, DT_CENTER | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER);
			GetClientRect(hwnd, &rc);
			FrameRect(mydc, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH));
			SelectObject(mydc, hfnt);
			DeleteObject(hbr);
		}
		break;

	case 2:
		{ //  Position
			HBRUSH hbr = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
			GetClientRect(hwnd, &rc);
			FillRect(mydc, &rc, hbr);
			DeleteObject(hbr);

			hbr = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
			GetClientRect(hwnd, &rc);
			rc.right -= 100;
			rc.top += 100;
			FillRect(mydc, &rc, hbr);
			DeleteObject(hbr);

			HPEN hpen = (HPEN)SelectObject(mydc, CreatePen(PS_DOT, 1, RGB(0, 0, 0)));
			MoveToEx(mydc, 0, 100, NULL);
			LineTo(mydc, 201, 100);
			MoveToEx(mydc, 100, 0, NULL);
			LineTo(mydc, 100, 201);
			DeleteObject(SelectObject(mydc, hpen));

			HRGN hrgn = CreateRectRgn(0, 0, 0, 0);
			GetWindowRgn(hwnd, hrgn);
			FrameRgn(mydc, hrgn, (HBRUSH)GetStockObject(BLACK_BRUSH), 1, 1);
			DeleteObject(hrgn);
		}
		break;
	}
}
Example #29
0
File: path.c Project: bilboed/wine
static void test_widenpath(void)
{
    HDC hdc = GetDC(0);
    HPEN greenPen, narrowPen;
    HPEN oldPen;
    POINT pnt[6];
    INT nSize, ret;

    /* Create a pen to be used in WidenPath */
    greenPen = CreatePen(PS_SOLID, 10, RGB(0,0,0));
    oldPen = SelectObject(hdc, greenPen);

    /* Prepare a path */
    pnt[0].x = 100;
    pnt[0].y = 0;
    pnt[1].x = 200;
    pnt[1].y = 0;
    pnt[2].x = 300;
    pnt[2].y = 100;
    pnt[3].x = 300;
    pnt[3].y = 200;
    pnt[4].x = 200;
    pnt[4].y = 300;
    pnt[5].x = 100;
    pnt[5].y = 300;

    /* Set a polyline path */
    BeginPath(hdc);
    Polyline(hdc, pnt, 6);
    EndPath(hdc);

    /* Widen the polyline path */
    ok(WidenPath(hdc), "WidenPath fails while widening a poyline path.\n");

    /* Test if WidenPath seems to have done his job */
    nSize = GetPath(hdc, NULL, NULL, 0);
    ok(nSize != -1, "GetPath fails after calling WidenPath.\n");
    ok(nSize > 6, "Path number of points is too low. Should be more than 6 but is %d\n", nSize);

    AbortPath(hdc);

    /* Test WidenPath with an open path (last error only set on Win2k and later) */
    SetLastError(0xdeadbeef);
    BeginPath(hdc);
    ret = WidenPath(hdc);
    ok(ret == FALSE && (GetLastError() == ERROR_CAN_NOT_COMPLETE || GetLastError() == 0xdeadbeef),
       "WidenPath fails while widening an open path. Return value is %d, should be %d. Error is %u\n", ret, FALSE, GetLastError());

    AbortPath(hdc);

    /* Test when the pen width is equal to 1. The path should change too */
    narrowPen = CreatePen(PS_SOLID, 1, RGB(0,0,0));
    oldPen = SelectObject(hdc, narrowPen);
    BeginPath(hdc);
    Polyline(hdc, pnt, 6);
    EndPath(hdc);
    ret = WidenPath(hdc);
    nSize = GetPath(hdc, NULL, NULL, 0);
    ok(nSize > 6, "WidenPath should compute a widdened path with a 1px wide pen. Path length is %d, should be more than 6\n", nSize);

    ReleaseDC(0, hdc);
    return;
}
Example #30
0
/*
================
rvGENavigator::WndProc

Window Procedure 
================
*/
LRESULT CALLBACK rvGENavigator::WndProc ( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
	rvGENavigator* nav = (rvGENavigator*) GetWindowLong ( hWnd, GWL_USERDATA );

	switch ( msg )
	{
		case WM_INITMENUPOPUP:
			return SendMessage ( gApp.GetMDIFrame ( ), msg, wParam, lParam );
	
		case WM_ACTIVATE:
			common->ActivateTool( LOWORD( wParam ) != WA_INACTIVE );
			break;

		case WM_ERASEBKGND:
			return TRUE;
		
		case WM_DESTROY:
			gApp.GetOptions().SetWindowPlacement ( "navigator", hWnd );
			break;
		
		case WM_CLOSE:		
			gApp.GetOptions().SetNavigatorVisible ( false );
			nav->Show ( false );
			return 0;

		case WM_DRAWITEM:
		{		
			DRAWITEMSTRUCT*	dis = (DRAWITEMSTRUCT*) lParam;
			idWindow*		window = (idWindow*)dis->itemData;
			
			if ( window )
			{
				rvGEWindowWrapper*	wrapper	= rvGEWindowWrapper::GetWrapper ( window );
				idStr				name    = window->GetName();
				RECT				rDraw;
				float				offset;
				bool				disabled;

				idWindow* parent = window;
				offset = 1;
				disabled = false;
				while ( parent = parent->GetParent ( ) )
				{
					if ( rvGEWindowWrapper::GetWrapper ( parent )->IsHidden ( ) )
					{
						disabled = true;
					}
					
					offset += 10;
				}
				
				CopyRect ( &rDraw, &dis->rcItem );
				rDraw.right = rDraw.left + GENAV_ITEMHEIGHT;
				rDraw.top ++;

				rDraw.right ++;
				FrameRect ( dis->hDC, &rDraw, (HBRUSH)GetStockObject ( BLACK_BRUSH ) );
				rDraw.right --;
			
				FillRect ( dis->hDC, &rDraw, GetSysColorBrush ( COLOR_3DFACE ) );

				Draw3dRect ( dis->hDC, &rDraw, GetSysColorBrush ( COLOR_3DHILIGHT ), GetSysColorBrush ( COLOR_3DSHADOW ) );

				InflateRect ( &rDraw, -3, -3 );
				Draw3dRect ( dis->hDC, &rDraw, GetSysColorBrush ( COLOR_3DSHADOW ), GetSysColorBrush ( COLOR_3DHILIGHT ) );
				
				if ( !wrapper->IsHidden ( ) )
				{
					DrawIconEx ( dis->hDC, rDraw.left, rDraw.top, disabled?nav->mVisibleIconDisabled:nav->mVisibleIcon, 16, 16,0, NULL, DI_NORMAL );
				}

				CopyRect ( &rDraw, &dis->rcItem );
				rDraw.left += GENAV_ITEMHEIGHT;
				rDraw.left += 1;
			
				if ( dis->itemState & ODS_SELECTED )
				{
					FillRect ( dis->hDC, &rDraw, GetSysColorBrush ( COLOR_HIGHLIGHT ) );			
				}
				else
				{
					FillRect ( dis->hDC, &rDraw, GetSysColorBrush ( COLOR_WINDOW ) );
				}

				if ( wrapper->CanHaveChildren ( ) && window->GetChildCount ( ) )
				{
					if ( wrapper->IsExpanded ( ) )
					{
						DrawIconEx ( dis->hDC, rDraw.left + offset, rDraw.top + 3, nav->mCollapseIcon, 16, 16,0, NULL, DI_NORMAL );								
					}
					else
					{
						DrawIconEx ( dis->hDC, rDraw.left + offset, rDraw.top + 3, nav->mExpandIcon, 16, 16,0, NULL, DI_NORMAL );								
					}
				}
			
				HPEN pen = CreatePen ( PS_SOLID, 1, GetSysColor ( COLOR_3DSHADOW ) );
				HPEN oldpen = (HPEN)SelectObject ( dis->hDC, pen );
				MoveToEx ( dis->hDC, rDraw.left, dis->rcItem.top, NULL );
				LineTo ( dis->hDC, dis->rcItem.right, dis->rcItem.top );
				MoveToEx ( dis->hDC, rDraw.left, dis->rcItem.bottom, NULL );
				LineTo ( dis->hDC, dis->rcItem.right, dis->rcItem.bottom);
				SelectObject ( dis->hDC, oldpen );
				DeleteObject ( pen );			

				rDraw.left += offset;
				rDraw.left += 20;
											
				int colorIndex = ( (dis->itemState & ODS_SELECTED ) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT );
				SetTextColor ( dis->hDC, GetSysColor ( colorIndex ) );
				DrawText ( dis->hDC, name, name.Length(), &rDraw, DT_LEFT|DT_VCENTER|DT_SINGLELINE );
							
				if ( wrapper->GetVariableDict().GetNumKeyVals ( ) || wrapper->GetScriptDict().GetNumKeyVals ( ) )
				{
					DrawIconEx ( dis->hDC, dis->rcItem.right - 16, (dis->rcItem.bottom+dis->rcItem.top)/2-6, (dis->itemState & ODS_SELECTED)?nav->mScriptsLightIcon:nav->mScriptsIcon, 13, 13,0, NULL, DI_NORMAL );
				}
			}
			
			break;
		}
	
		case WM_MEASUREITEM:
		{
			MEASUREITEMSTRUCT* mis = (MEASUREITEMSTRUCT*) lParam;
			mis->itemHeight = 22;
			break;
		}
	
		case WM_CREATE:
		{
			LPCREATESTRUCT	cs;
			LVCOLUMN		col;
			
			// Attach the class to the window first
			cs = (LPCREATESTRUCT) lParam;
			nav = (rvGENavigator*) cs->lpCreateParams;
			SetWindowLong ( hWnd, GWL_USERDATA, (LONG)nav );

			// Create the List view
			nav->mTree = CreateWindowEx ( 0, "SysListView32", "", WS_VSCROLL|WS_CHILD|WS_VISIBLE|LVS_REPORT|LVS_OWNERDRAWFIXED|LVS_NOCOLUMNHEADER|LVS_SHOWSELALWAYS, 0, 0, 0, 0, hWnd, (HMENU)IDC_GUIED_WINDOWTREE, win32.hInstance, 0 );
			ListView_SetExtendedListViewStyle ( nav->mTree, LVS_EX_FULLROWSELECT );
			ListView_SetBkColor ( nav->mTree, GetSysColor ( COLOR_3DFACE ) );
			ListView_SetTextBkColor ( nav->mTree, GetSysColor ( COLOR_3DFACE ) );
			nav->mListWndProc = (WNDPROC)GetWindowLong ( nav->mTree, GWL_WNDPROC );
			SetWindowLong ( nav->mTree, GWL_USERDATA, (LONG)nav );
			SetWindowLong ( nav->mTree, GWL_WNDPROC, (LONG)ListWndProc );

			// Insert the only column
			col.mask = 0;	
			ListView_InsertColumn ( nav->mTree, 0, &col );
							
			break;
		}
	
		case WM_SIZE:
		{
			RECT rClient;
			MoveWindow ( nav->mTree, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE );
			GetClientRect ( nav->mTree, &rClient );		
			ListView_SetColumnWidth ( nav->mTree, 0, rClient.right-rClient.left-1 );
			break;
		}

		case WM_NCACTIVATE:
			return gApp.ToolWindowActivate ( gApp.GetMDIFrame(), msg, wParam, lParam );
				
		case WM_NOTIFY:
		{
			LPNMHDR nh;
			
			nh = (LPNMHDR) lParam;
			
			switch ( nh->code )
			{				
				case NM_CLICK:
				case NM_DBLCLK:
				{
					DWORD dwpos = GetMessagePos(); 
					LVHITTESTINFO info;
					info.pt.x = LOWORD(dwpos);
					info.pt.y = HIWORD(dwpos);		
					MapWindowPoints(HWND_DESKTOP, nh->hwndFrom, &info.pt, 1);      
					int index = ListView_HitTest ( nav->mTree, &info );
					if ( index != -1 )
					{
						RECT	rItem;
						int		offset;
						ListView_GetItemRect ( nav->mTree, index, &rItem, LVIR_BOUNDS );
						LVITEM item;
						item.mask = LVIF_PARAM;
						item.iItem = index;
						ListView_GetItem ( nav->mTree, &item );
						idWindow* window = (idWindow*)item.lParam;
						rvGEWindowWrapper* wrapper = rvGEWindowWrapper::GetWrapper(window);

						offset = wrapper->GetDepth ( ) * 10 + 1;

						if ( info.pt.x < GENAV_ITEMHEIGHT )
						{
							if ( !rvGEWindowWrapper::GetWrapper(window)->IsHidden ( ) )
							{
								nav->mWorkspace->HideWindow ( window );
							}
							else
							{
								nav->mWorkspace->UnhideWindow ( window );
							}
						}						
						else if ( info.pt.x > GENAV_ITEMHEIGHT + offset && info.pt.x < GENAV_ITEMHEIGHT + offset + 16 )
						{
							if ( wrapper->CanHaveChildren ( ) && window->GetChildCount ( ) )
							{
								if ( wrapper->IsExpanded ( ) )
								{
									wrapper->Collapse ( );
									nav->Update ( );
								}
								else
								{
									wrapper->Expand ( );
									nav->Update ( );
								}
							}
						}
						else if ( nh->code == NM_DBLCLK )
						{
							SendMessage ( gApp.GetMDIFrame ( ), WM_COMMAND, MAKELONG(ID_GUIED_ITEM_PROPERTIES,0), 0 );
						}											
					}
					
					break;
				}
				
				case NM_RCLICK:
				{
					DWORD dwpos = GetMessagePos(); 
					LVHITTESTINFO info;
					info.pt.x = LOWORD(dwpos);
					info.pt.y = HIWORD(dwpos);		
					MapWindowPoints(HWND_DESKTOP, nh->hwndFrom, &info.pt, 1);      
					int index = ListView_HitTest ( nav->mTree, &info );
					
					if ( index != -1 )
					{				
						ClientToScreen ( hWnd, &info.pt );
						HMENU menu = GetSubMenu ( LoadMenu ( gApp.GetInstance(), MAKEINTRESOURCE(IDR_GUIED_ITEM_POPUP) ), 0 );
						TrackPopupMenu ( menu, TPM_RIGHTBUTTON|TPM_LEFTALIGN, info.pt.x, info.pt.y, 0, gApp.GetMDIFrame ( ), NULL );
						DestroyMenu ( menu );
					}
					
					break;					
				}
								
				case LVN_ITEMCHANGED:
				{
					NMLISTVIEW* nml = (NMLISTVIEW*) nh;
					if ( (nml->uNewState & LVIS_SELECTED) != (nml->uOldState & LVIS_SELECTED) )
					{
						LVITEM item;
						item.iItem = nml->iItem;
						item.mask = LVIF_PARAM;
						ListView_GetItem ( nav->mTree, &item );
						
						if ( nml->uNewState & LVIS_SELECTED )
						{
							nav->mWorkspace->GetSelectionMgr().Add ( (idWindow*)item.lParam, false );
						}
						else
						{
							nav->mWorkspace->GetSelectionMgr().Remove ( (idWindow*)item.lParam );
						}	
					}
					break;
				}
			}
			
			break;
		}	
	}

	return DefWindowProc ( hWnd, msg, wParam, lParam );
}