void CDownloadClientsCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	if (!theApp.emuledlg->IsRunning())
		return;
	if (!lpDrawItemStruct->itemData)
		return;

	// ==> Visual Studio 2010 Compatibility [Stulle/Avi-3k/ied] - Stulle
	/*
	CMemDC dc(CDC::FromHandle(lpDrawItemStruct->hDC), &lpDrawItemStruct->rcItem);
	*/
	CMemoryDC dc(CDC::FromHandle(lpDrawItemStruct->hDC), &lpDrawItemStruct->rcItem);
	// <== Visual Studio 2010 Compatibility [Stulle/Avi-3k/ied] - Stulle
	BOOL bCtrlFocused;
	//Xman narrow font at transferwindow
	/*
	InitItemMemDC(dc, lpDrawItemStruct, bCtrlFocused);
	*/
	InitItemMemDC(dc, lpDrawItemStruct, bCtrlFocused, true);
	//Xman end
	CRect cur_rec(lpDrawItemStruct->rcItem);
	CRect rcClient;
	GetClientRect(&rcClient);
	const CUpDownClient *client = (CUpDownClient *)lpDrawItemStruct->itemData;

	COLORREF crOldBackColor = dc->GetBkColor();  //Xman show LowIDs
	CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl();
	int iCount = pHeaderCtrl->GetItemCount();
	cur_rec.right = cur_rec.left - sm_iLabelOffset;
	cur_rec.left += sm_iIconOffset;
	for (int iCurrent = 0; iCurrent < iCount; iCurrent++)
	{
		int iColumn = pHeaderCtrl->OrderToIndex(iCurrent);
		if (!IsColumnHidden(iColumn))
		{
			UINT uDrawTextAlignment;
			int iColumnWidth = GetColumnWidth(iColumn, uDrawTextAlignment);
			cur_rec.right += iColumnWidth;
			if (cur_rec.left < cur_rec.right && HaveIntersection(rcClient, cur_rec))
			{
				TCHAR szItem[1024];
				GetItemDisplayText(client, iColumn, szItem, _countof(szItem));
				switch (iColumn)
				{
					case 0:{
						int iImage;
						//Xman Show correct Icons
						/*
						if (client->credits != NULL)
						{
							if (client->IsFriend())
								iImage = 4;
							else if (client->GetClientSoft() == SO_EDONKEYHYBRID) {
								if (client->credits->GetScoreRatio(client->GetIP()) > 1)
									iImage = 8;
								else
									iImage = 7;
							}
							else if (client->GetClientSoft() == SO_MLDONKEY) {
								if (client->credits->GetScoreRatio(client->GetIP()) > 1)
									iImage = 6;
								else
									iImage = 5;
							}
							else if (client->GetClientSoft() == SO_SHAREAZA) {
								if (client->credits->GetScoreRatio(client->GetIP()) > 1)
									iImage = 10;
								else
									iImage = 9;
							}
							else if (client->GetClientSoft() == SO_AMULE) {
								if (client->credits->GetScoreRatio(client->GetIP()) > 1)
									iImage = 12;
								else
									iImage = 11;
							}
							else if (client->GetClientSoft() == SO_LPHANT) {
								if (client->credits->GetScoreRatio(client->GetIP()) > 1)
									iImage = 14;
								else
									iImage = 13;
							}
							else if (client->ExtProtocolAvailable()) {
								if (client->credits->GetScoreRatio(client->GetIP()) > 1)
									iImage = 3;
								else
									iImage = 1;
							}
							else {
								if (client->credits->GetScoreRatio(client->GetIP()) > 1)
									iImage = 2;
								else
									iImage = 0;
							}
						}
						else
							iImage = 0;
						*/
						if (client->IsFriend())
							iImage = 6;
						else if (client->GetClientSoft() == SO_EDONKEYHYBRID){
							iImage = 10;
						}
						else if (client->GetClientSoft() == SO_EDONKEY){
							iImage = 2;
						}
						else if (client->GetClientSoft() == SO_MLDONKEY){
							iImage = 8;
						}
						else if (client->GetClientSoft() == SO_SHAREAZA){
							iImage = 12;
						}
						else if (client->GetClientSoft() == SO_AMULE){
							iImage = 14;
						}
						else if (client->GetClientSoft() == SO_LPHANT){
							iImage = 16;
						}
						else if (client->ExtProtocolAvailable()){
							iImage = 4;
						}
						else{
							iImage = 0;
						}
						//Xman Anti-Leecher
						if(client->IsLeecher()>0)
							iImage = 18;
						else
						//Xman end
						if (((client->credits)?client->credits->GetMyScoreRatio(client->GetIP()):0) > 1)
							iImage++;
						//Xman end

						UINT nOverlayImage = 0;
						if ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED))
							nOverlayImage |= 1;
						//Xman changed: display the obfuscation icon for all clients which enabled it
						/*
						if (client->IsObfuscatedConnectionEstablished())
						*/
						if(client->IsObfuscatedConnectionEstablished() 
							|| (!(client->socket != NULL && client->socket->IsConnected())
							&& (client->SupportsCryptLayer() && thePrefs.IsClientCryptLayerSupported() && (client->RequestsCryptLayer() || thePrefs.IsClientCryptLayerRequested()))))
						//Xman end
							nOverlayImage |= 2;
						int iIconPosY = (cur_rec.Height() > 16) ? ((cur_rec.Height() - 16) / 2) : 1;
						POINT point = { cur_rec.left, cur_rec.top + iIconPosY };
						m_ImageList.Draw(dc, iImage, point, ILD_NORMAL | INDEXTOOVERLAYMASK(nOverlayImage));

						//Xman friend visualization
						if (client->IsFriend() && client->GetFriendSlot())
							m_ImageList.Draw(dc,19, point, ILD_NORMAL);
						//Xman end

						//EastShare Start - added by AndCycle, IP to Country 
						if(theApp.ip2country->ShowCountryFlag()){
							cur_rec.left+=20;
							POINT point2= {cur_rec.left,cur_rec.top+1};
							//int index = client->GetCountryFlagIndex();
							//theApp.ip2country->GetFlagImageList()->DrawIndirect(dc, index , point2, CSize(18,16), CPoint(0,0), ILD_NORMAL);
							theApp.ip2country->GetFlagImageList()->DrawIndirect(&theApp.ip2country->GetFlagImageDrawParams(dc,client->GetCountryFlagIndex(),point2));
							cur_rec.left += sm_iLabelOffset;
						}
						//EastShare End - added by AndCycle, IP to Country

						cur_rec.left += 16 + sm_iLabelOffset;
						dc.DrawText(szItem, -1, &cur_rec, MLC_DT_TEXT | uDrawTextAlignment);
						cur_rec.left -= 16;
						cur_rec.right -= sm_iSubItemInset;

						//EastShare Start - added by AndCycle, IP to Country
						if(theApp.ip2country->ShowCountryFlag()){
							cur_rec.left-=20;
							cur_rec.left -= sm_iLabelOffset;
						}
						//EastShare End - added by AndCycle, IP to Country
						break;
					}

					case 4:
					{ //Xman
						cur_rec.bottom--;
						cur_rec.top++;
						COLORREF crOldBackColor = dc->GetBkColor(); //Xman Code Improvement: FillSolidRect
						client->DrawStatusBar(dc, &cur_rec, false, thePrefs.UseFlatBar());
						dc.SetBkColor(crOldBackColor); //Xman Code Improvement: FillSolidRect
						//Xman client percentage (font idea by morph)
						CString buffer;
						if (thePrefs.GetUseDwlPercentage())
						{
							if(client->GetHisCompletedPartsPercent_Down() >=0)
							{
								COLORREF oldclr = dc.SetTextColor(RGB(0,0,0));
								int iOMode = dc.SetBkMode(TRANSPARENT);
								buffer.Format(_T("%i%%"), client->GetHisCompletedPartsPercent_Down());
								CFont *pOldFont = dc.SelectObject(&m_fontBoldSmaller);
#define	DrawClientPercentText	dc.DrawText(buffer, buffer.GetLength(),&cur_rec, ((MLC_DT_TEXT | DT_RIGHT) & ~DT_LEFT) | DT_CENTER)
								cur_rec.top-=1;cur_rec.bottom-=1;
								DrawClientPercentText;cur_rec.left+=1;cur_rec.right+=1;
								DrawClientPercentText;cur_rec.left+=1;cur_rec.right+=1;
								DrawClientPercentText;cur_rec.top+=1;cur_rec.bottom+=1;
								DrawClientPercentText;cur_rec.top+=1;cur_rec.bottom+=1;
								DrawClientPercentText;cur_rec.left-=1;cur_rec.right-=1;
								DrawClientPercentText;cur_rec.left-=1;cur_rec.right-=1;
								DrawClientPercentText;cur_rec.top-=1;cur_rec.bottom-=1;
								DrawClientPercentText;cur_rec.left++;cur_rec.right++;
								dc.SetTextColor(RGB(255,255,255));
								DrawClientPercentText;
								dc.SelectObject(pOldFont);
								dc.SetBkMode(iOMode);
								dc.SetTextColor(oldclr);
							}
						}
						//Xman end
						cur_rec.bottom++;
						cur_rec.top--;
						break;
					} //Xman

					default:
						//Xman show LowIDs
						if(iColumn == 1 && client->HasLowID()) 
							dc.SetBkColor(RGB(255,250,200));
						//Xman End
						dc.DrawText(szItem, -1, &cur_rec, MLC_DT_TEXT | uDrawTextAlignment);
						dc.SetBkColor(crOldBackColor); //Xman show LowIDs
						break;
				}
			}
			cur_rec.left += iColumnWidth;
		}
	}

	DrawFocusRect(dc, lpDrawItemStruct->rcItem, lpDrawItemStruct->itemState & ODS_FOCUS, bCtrlFocused, lpDrawItemStruct->itemState & ODS_SELECTED);
}
Example #2
0
void TViewEntryDialog::EvDrawItem (UINT ctrlId, DRAWITEMSTRUCT& drawInfo)
#endif
{
	char Buf[128];

	// To be sure
	if ( CurrentEntry == NULL )
		return;

	// To be sure
	if ( ctrlId != IDC_VE_DUMP_LIST )
		return;

	// If there are no list box items, skip this message.
	if ( drawInfo.itemID == (UINT)-1 )
		return;

	// Build string to draw
	strcpy (Buf, "");
	if ( drawInfo.itemID == 0 )
	{
		char entryname[9];

		strncpy (entryname, CurrentEntry->dir.name, 8);
		entryname[8] = '\0';
		sprintf(Buf, "Contents of entry %s (size = %ld bytes):",
					 entryname, CurrentEntry->dir.size);
	}
	else
	{
		// Starting Offset in the entry
		ULONG EntryOffset = (ULONG)(drawInfo.itemID - 1) * NB_HEX_LINE;

		// Starting Offset in the wad file
		ULONG WadOffset   = CurrentEntry->dir.start + EntryOffset;

		// Number of chars for this line
		USHORT NbChars    = min(NB_HEX_LINE,
								(USHORT)(CurrentEntry->dir.size - EntryOffset));

		// Bytes of the line
		unsigned char HexBuf[NB_HEX_LINE];

		// Line len
		int len;
		int i;

		BasicWadSeek (CurrentEntry->wadfile, WadOffset);

		// Dump offset
		len = sprintf(Buf, "%06lX:\t", EntryOffset);

		// 16 hex values
		for (i = 0 ; i < NbChars ; i++)
		{
			BasicWadRead (CurrentEntry->wadfile, &(HexBuf[i]), 1);

			len += sprintf (&Buf[len], "%02X\t", HexBuf[i]);
		}

		// Add padding tabs
		for (; i < NB_HEX_LINE ; i++)
			len += sprintf(&Buf[len], "\t");
		// len += sprintf (&Buf[len], "\t");

		// 16 chars
		for (i = 0 ; i < NbChars ; i++)
		{
			char c = HexBuf[i];
			if ( ! isprint(c) )
				c = ' ';

			len += sprintf (&Buf[len], "%c", c);
		}
	}

	switch (drawInfo.itemAction)
	{
		case ODA_SELECT:
		case ODA_DRAWENTIRE:
		{
			// Retreive the average character width
			TEXTMETRIC tm;
			GetTextMetrics(drawInfo.hDC, &tm);

			// Setup tab stops in HexDump list
			int TabStops[NB_HEX_LINE+1];
			int i;

			TabStops[0] = 6 * tm.tmAveCharWidth;
			for (i = 1 ; i < NB_HEX_LINE ; i++)
				TabStops[i] = TabStops[i-1] + 3 * tm.tmAveCharWidth + 2;
			TabStops[i] = TabStops[i-1] + 4 * tm.tmAveCharWidth;

			TabbedTextOut(drawInfo.hDC,
						  drawInfo.rcItem.left, drawInfo.rcItem.top,
						  Buf, strlen(Buf),
						  NB_HEX_LINE+2, TabStops, 0);
#if 0
			/* Is the item selected? */
			if (drawInfo.itemState & ODS_SELECTED)
			{
				/* Draw a rectangle around bitmap to indicate the selection. */
				DrawFocusRect(drawInfo.hDC, &drawInfo.rcItem);
			}
#endif
		}
		break;

		case ODA_FOCUS:
			/*
			 * Do not process focus changes. The focus caret (outline
			 * rectangle) indicates the selection. The Which one? (IDOK)
			 * button indicates the final selection.
			 */
		  break;
	}
}
Example #3
0
//-----------------------------------------------------------------------=
                                                        // ÚÄ1ra Col.a Pintar
                                                        // ³
static void near PaintTheLine( HDC hDC, RECT * rct, WORD wIndex,
                               PCLIPVAR pAtext, PCLIPVAR pAsizes,
                               HPEN hWhitePen, HPEN hGrayPen, BOOL bTree,
                               PCLIPVAR pAJustify, WORD wPressed,
                               BOOL bHeader, WORD nStyle,
                               WORD wFocus, BOOL bFocused,
                               PCLIPVAR pTextColor, PCLIPVAR pBkColor,
                               WORD wRowPos, WORD nHeightCtrl,
                               LONG nClrLine, BOOL bFooter,
                               BOOL bSelect, PCLIPVAR pFont,
                               BOOL bDrawFocusRect )
{
   RECT box, wholebox, rctadj;
   int iMaxRight = rct->right;

   WORD wLenJust = 0 ;
   #ifndef __HARBOUR__
   WORD wLen     = _VARRAYLEN( pAtext );
   CLV_WORD lJustify;
   #else
   WORD wLen     = hb_arrayLen( pAtext );
   PHB_ITEM uElem = hb_itemNew( NULL );
   #endif
   WORD wType, wcLen;
   LONG lValue;
   char * cValue;
   HPEN hOldPen, hPen;
   BITMAP bmp;
   WORD wRow, wCol;
   LONG lColor ;
   HBRUSH hBrush;
   LONG lTextColorOld = -1 ; // CeSoTech
   LONG lBkColorOld   = -1 ; // CeSoTech
   PCLIPVAR pEvalOld ;
   HFONT hFont ; // CeSoTech
   WORD wAlign ; // CeSoTech

   // CeSoTech
   LONG nClrLineC = ( nStyle == 2 || nStyle == 6 || nStyle == 8 ||
                      nStyle == 10 ) ? GetSysColor( COLOR_BTNSHADOW ) : 0 ;

   // CeSoTech
   if ( nClrLine >= 0 )   // Desde Clipper manda color especifico linea
      nClrLineC = nClrLine ;

   if ( ! bDrawHeaders )
      bHeader = FALSE ;

   if ( bFooter )
      bHeader = TRUE ; //-> Para que lo pinte con similar aspecto

   //CeSoTech
   // Si es un estilo sin separadores horizontales, pintar uno mas arriba
   //CeSoTech para que que bien completa el area !!!
   if ( ! (bHeader) && (nStyle == 0 || nStyle == 5 || nStyle == 6 ||
                        nStyle == 9 || nStyle == 10) )
      rct->top--       ;

   wholebox.top    = rct->top+1;
   wholebox.left   = rct->left;
   wholebox.bottom = rct->bottom;
   wholebox.right  = rct->right;

   rct->right  = 0;

   box.top    = rct->top ;
   box.bottom = rct->bottom - 1;

   if( !wIndex | wIndex > wLen )
       wIndex = 1;

   if ( pAJustify )
      #ifndef __HARBOUR__
         wLenJust = _VARRAYLEN( pAJustify );
      #else
         wLenJust = hb_arrayLen( pAJustify );
      #endif

   while( wIndex <= wLen )
   {

        rct->left   = rct->right;

        rct->right  = ( wIndex == wLen ? iMaxRight
                                      : rct->left + GetInt( pAsizes, wIndex ) );
        // CeSoTech // Cuando estoy estoy en la ultima celda, NO pintar hasta
                    // el final si no existe ajuste de ultima columna.
        if ( ( wIndex == wLen ) && ( ! bAdjLastCol )  )
        {
           rct->right  = rct->left + GetInt( pAsizes, wIndex ) +(bHeader ? 1: 0) ;
           if ( !bAdjBrowse )
              wholebox.right = rct->right ; // Tambien ajusto el borde focus

        }
        // CeSoTech //


        wAlign = HA_LEFT | VA_CENTER ;  // Alineacion por defecto
        wcLen = 0;
        ///////// INICIO Toma de datos celda !!!

        #ifndef __HARBOUR__
           if ( wIndex <= wLenJust )
           {
             _cAt( pAJustify, wIndex, 0xFFFF, ( PCLIPVAR ) &lJustify );
             wAlign = lJustify.wWord ;
           }
           _cAt( pAtext, wIndex, 0xFFFF, ++_tos );
           wType = _tos->wType;
           if ( wType & NUMERIC )
              lValue = (LONG) _tos->pPointer1;
           if ( wType & CHARACTER )
           {
              cValue = _VSTR( _tos );
              wcLen = _tos->w2;
           }
        #else

           if ( wIndex <= wLenJust )
           {
              hb_arrayGet( pAJustify, wIndex, uElem );
              if ( ( hb_itemType( uElem ) & LOGICAL ) && hb_itemGetL( uElem ) )
                 wAlign = HA_RIGHT | VA_CENTER ;
              else
                 wAlign = hb_itemGetNL( uElem );

			        hb_itemClear( uElem );
           }

           // uElem.type = HB_IT_NIL;
           hb_arrayGet( pAtext, wIndex, uElem );
           wType = hb_itemType( uElem );
           if ( wType & NUMERIC )
              lValue = hb_itemGetNL( uElem );
           if ( wType & CHARACTER )
           {
//              cValue = hb_itemGetC( uElem );
				cValue = hb_itemGetCPtr( uElem );
                wcLen = strlen( cValue );
           }

        #endif
        ///////// FIN Toma de datos celda !!!



        if( wFocus > 0 && wIndex != wFocus )
        {
           #ifndef __HARBOUR__
              _tos--;
           #endif

           if( rct->right >= iMaxRight )
           {
               wIndex = wLen + 1;   // ya no pintamos m s
           }
           else
              ++wIndex;
           continue;
        }

        if( bTree ||
            (GetInt( pAsizes, wIndex ) > 0) ) //Si NO es columna oculta (x Freeze)
        {                                     //(Es lo mismo no hacer esto,
                                              // pero es para evitar hacer trabajar
                                              // al codigo sin sentido !!! )

           if( (wType & NUMERIC) && bTree )
           {
               if( lValue )
               {
                  FillRect( hDC, rct, hBrush = CreateSolidBrush( GetPixel( hDC, rct->left, rct->top ) ) );
                  DrawMasked( hDC, (HBITMAP) lValue, rct->top, rct->left );
                  DeleteObject( hBrush );
               }

           }
           else  // Si es Numerico Bmp no Tree, o , es Character !!!!
           {

               if ( pBkColor )  // Bloque de Color Fondo Celda
               {
                  _PutSym( _SymEval );
                  _xPushM( pBkColor );
                  _PutLN( wRowPos );
                  _PutLN( wIndex );
                  _PutLN( bFooter ? 2 : ( bHeader ? 1 : ( bSelect ? 3 : 0 ) ) );
                  _xEval( 3 ) ;
                  if ( _parinfo( -1 ) & NUMERIC )
                    lBkColorOld = SetBkColor( hDC, _parnl( - 1 ) ) ;
               }

               if( pTextColor ) // Bloque de Color Texto Celda
               {
                  _PutSym( _SymEval );
                  _xPushM( pTextColor );
                  _PutLN( wRowPos );
                  _PutLN( wIndex );
                  _PutLN( bFooter ? 2 : ( bHeader ? 1 : ( bSelect ? 3 : 0 ) ) );
                  _xEval( 3 ) ;
                  if ( _parinfo( -1 ) & NUMERIC )
                    lTextColorOld = SetTextColor( hDC, _parnl( - 1 ) ) ;
               }

               hFont = 0 ;
               if( pFont )      // Bloque de Font Celda
               {
                  _PutSym( _SymEval );
                  _xPushM( pFont );
                  _PutLN( wRowPos );
                  _PutLN( wIndex );
                  _PutLN( bFooter ? 2 : ( bHeader ? 1 : ( bSelect ? 3 : 0 ) ) );
                  _xEval( 3 ) ;
                  if ( _parinfo( -1 ) & NUMERIC )
                     hFont = (HFONT) _parnl( - 1 ) ;
               }


               /////// CeSoTech ///////
               if (!bHeader) rct->top ++;


               if( wType & NUMERIC )   // Es un BitMap
               {
                  FW_DrawBitmapCenter( hDC, (HBITMAP) lValue, rct, nStyle, bSelect );
               }
               else                    // Es una Cadena
               {
                  FW_DrawText( hDC, rct,
                               ( wType & CHARACTER ) ? cValue : "",
                               wAlign, wcLen, hFont, bHeader ) ;
               }


               /////// CeSoTech restauracion de colores //////
               if ( lTextColorOld >= 0 )
               {
                  SetTextColor( hDC, lTextColorOld ) ;
                  lTextColorOld = -1 ;
               }
               if ( lBkColorOld >= 0 )
               {
                  SetBkColor( hDC, lBkColorOld ) ;
                  lBkColorOld = -1 ;
               }


               /// CeSoTech ///
               // Si hay modalidad ajustar el Browse y no hay ajuste de ultima
               // columna, deber‚ pintar hasta el final hasta cubrir toda
               // el area, hasta llegar a la derecha del control. (Col.Ficticia)
               if ( bAdjBrowse && wIndex == wLen && !bAdjLastCol &&
                    rct->right <= iMaxRight )
               {
                  rctadj.top    = rct->top;
                  rctadj.left   = rct->right ;
                  rctadj.bottom = rct->bottom;
                  rctadj.right  = wholebox.right  ;

                  if ( nStyle == 3 )
                     rctadj.top--;

                  if ( wFocus == 0 )  // Si No es CellStyle (Pinto hasta final)
                     ExtTextOut( hDC, 0, rct->top, ETO_OPAQUE, &rctadj, "", 0, 0 );

                  if ( bHeader && nStyle==3 ) // Pinto Bordes Header Falso
                   {
                      rctadj.right  = wholebox.right - 2  ;
                      rctadj.bottom = rctadj.bottom - 2 ;
                      WndDrawBox( hDC, &rctadj, hWhitePen, hGrayPen );
                      rctadj.bottom++  ;
                      rctadj.right++  ;
                      WndDrawBox( hDC, &rctadj, hWhitePen, GetStockObject( BLACK_PEN ) );

                      if ( bFooter ) // Si es Footer (Linea Negra de Arriba Foot)
                      {
                        hPen = GetStockObject( BLACK_PEN );
                        hOldPen = SelectObject( hDC, hPen );
                        MoveTo( hDC, rctadj.left-1, rctadj.top-1 );
                        LineTo( hDC, rctadj.right+1, rctadj.top-1 );
                        SelectObject( hDC, hOldPen );
                      }

                  }

               }
               /// CeSoTech Fin ///

               if (!bHeader) rct->top --;
           }

           box.left   = rct->left;

           box.right  = ( wIndex < wLen && rct->right <= iMaxRight ?
                                                        rct->right - 1 :
                                                        iMaxRight - 1 );

           // CeSoTech // El Borde derecho de Box de la ultima columna,
                       // no estirarlo cuando no exista ajuste de ultima columna
                       // PERO cuando nLineStyle (nStyle) es 7/8 (Lineas Horiz)
                       // queda anti-estetico cortar los renglones, cuando no hay
                       // ajuste ult.col. y hay ajuste de browse. Por ello
                       // se verificara que para cortar el borde no se de esta
                       // condicion.
           if ( ( wIndex == wLen ) && ( ! bAdjLastCol ) )
           {
              if (! (!bHeader && (nStyle==7 || nStyle==8) && !bAdjLastCol && bAdjBrowse) )
               box.right  = rct->left + GetInt( pAsizes, wIndex ) - 1 ;
           }
           // CeSoTech //



           if( ! bTree )
           {
              if( wPressed && ( wIndex == wPressed ) )
              {
                WndDrawBox( hDC, &box, hGrayPen, hWhitePen );
              }
              else
/////////////  if(!bHeader)
               if(!bHeader || (bHeader && nStyle!=3) )
               {
                  switch( nStyle )
                  {
                     case 0:
                        break;
                     case 1:
                    //  hOldPen = SelectObject( hDC, GetStockObject( BLACK_PEN ) );
                        hPen = CreatePen(PS_SOLID, 0, nClrLineC );
                        hOldPen = SelectObject( hDC, hPen);
                        MoveTo( hDC, box.left, box.bottom+1 );
                        LineTo( hDC, box.left, box.top );
                        LineTo( hDC, box.right+1, box.top );
                        LineTo( hDC, box.right+1,  box.bottom+1 );
                        LineTo( hDC, box.left, box.bottom+1 );
                        SelectObject( hDC, hOldPen );
                        DeleteObject( hPen);
                        break;
                     case 2:
                        hPen = CreatePen(PS_SOLID, 0, nClrLineC );
                        hOldPen = SelectObject( hDC, hPen);
                        MoveTo( hDC, box.left, box.bottom+1 );
                        LineTo( hDC, box.left, box.top );
                        LineTo( hDC, box.right+1, box.top );
                        LineTo( hDC, box.right+1,  box.bottom+1 );
                        LineTo( hDC, box.left, box.bottom+1 );
                        SelectObject( hDC, hOldPen );
                        DeleteObject( hPen);
                        break;
                     case 3:
                        WndDrawBox( hDC, &box, hWhitePen, hGrayPen );
                        break;
                     case 4:
                        box.bottom ++;
                        box.right ++;
                        FrameDot( hDC, &box );
                        box.bottom --;
                        box.right --;
                        break;
                     case 7:
                     case 8:
                        hPen = CreatePen(PS_SOLID, 0, nClrLineC );
                        hOldPen = SelectObject( hDC, hPen);
                        MoveTo( hDC, box.left, box.top );
                        LineTo( hDC, box.right+1, box.top );
                        MoveTo( hDC, box.right+1,  box.bottom+1 );
                        LineTo( hDC, box.left, box.bottom+1 );
                        SelectObject( hDC, hOldPen );
                        DeleteObject( hPen);
                        break;
                     case 5:
                     case 6:
                     case 9:
                     case 10:
                        hPen = CreatePen(PS_SOLID, 0, nClrLineC);
                        hOldPen = SelectObject( hDC, hPen);
                        if (box.left>1)
                        {
                           MoveTo( hDC, box.left, box.bottom+1 );
                           LineTo( hDC, box.left, box.top );
                        }
                        MoveTo( hDC, box.right+1, box.top );

                        if ( bDrawFooters && nStyle >= 9 )
                        {
                        LineTo( hDC, box.right+1,
                                     nHeightCtrl - (wFooterHeight+1) ) ;
                        } else {
                          LineTo( hDC, box.right+1,
                                     nStyle < 9 ? box.bottom+1 : nHeightCtrl );
                        }

                        SelectObject( hDC, hOldPen );
                        DeleteObject( hPen);
                        break;
                  }
               }
               else  // Box para Headers !!!
               {
                  box.left ++;

                  // CeSoTech
                  if ( bFooter ) // Linea negra sobre el Footer
                  {
                    hPen = GetStockObject( BLACK_PEN );
                    hOldPen = SelectObject( hDC, hPen );
                    MoveTo( hDC, box.left-1, box.top-1 );
                    LineTo( hDC, box.right+1, box.top-1 );
                    SelectObject( hDC, hOldPen );
                  }

                  box.right--  ;
                  box.bottom-- ;
                  WndDrawBox( hDC, &box, hWhitePen, hGrayPen );
                  box.bottom++  ;
                  box.right++  ;
                  WndDrawBox( hDC, &box, hWhitePen, GetStockObject( BLACK_PEN ) );

                  box.left --;

               }
           }
           else
           {
              if( ! ( wType & NUMERIC ) )
              {
                 box.left -= 16;
              }
           }

          // CeSoTech if( bFocused && wFocus > 0 && wIndex == wFocus )
           if( bDrawFocusRect && bFocused && wFocus > 0 &&
               wIndex == wFocus && nStyle != 3)
           {
            rct->left++;
            rct->top++;
            DrawFocusRect( hDC, rct );
            rct->left--;
            rct->top--;
           }

        }

        #ifndef __HARBOUR__
           _tos--;
        #endif

        if( rct->right >= iMaxRight )
        {
            wIndex = wLen + 1;   // ya no pintamos m s
        }
        else
           ++wIndex;


   }

   if (bDrawFocusRect && !bTree && bFocused && wFocus==0 && nStyle!=3) // CeSoTech
      DrawFocusRect( hDC, &wholebox );

  hb_itemRelease( uElem );
}
Example #4
0
static void onDrawItem(LPDRAWITEMSTRUCT lpdis, BOOL bDrive) 
{
  if((int)lpdis->itemID < 0)
    return;

  char szItem[_MAX_DIR];
  DWORD dwItemData;

  if(bDrive) 
  {
    dwItemData = ComboBox_GetItemData(lpdis->hwndItem, lpdis->itemID);
    ComboBox_GetLBText(lpdis->hwndItem, lpdis->itemID, szItem);
  } 
  else 
  {
    dwItemData = ListBox_GetItemData(lpdis->hwndItem, lpdis->itemID);
    ListBox_GetText(lpdis->hwndItem, lpdis->itemID, szItem);
  }

  if(lpdis->itemAction & (ODA_DRAWENTIRE | ODA_SELECT)) 
  {
    COLORREF colorText;
    COLORREF colorBack;
    if(lpdis->itemState & ODS_SELECTED) 
    {
      colorText = SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
      colorBack = SetBkColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
    }
    HICON hIcon;
    int indent = 0;
    if(bDrive) 
    {
      int iType=(int)HIWORD(dwItemData);
      switch (iType) 
      {
        case DRIVE_REMOVABLE:
          hIcon = hIconDrives[0];
          break; 
        case DRIVE_FIXED:
          hIcon = hIconDrives[1];
          break;
        case DRIVE_REMOTE:
          hIcon = hIconDrives[2];
          break; 
        case DRIVE_CDROM:
          hIcon = hIconDrives[3];
          break; 
        case DRIVE_RAMDISK:
          hIcon = hIconDrives[4];
          break; 
      }

    } 
    else 
    {
      int iconID = (int)HIWORD(lpdis->itemData);
      switch (iconID) 
      {
        case ID_ICON_FOLDERCLOSED:
          hIcon = hIconFolders[0];
          break;
        case ID_ICON_FOLDEROPEN:
          hIcon = hIconFolders[1];
          break;
        case ID_ICON_OPENSELECT:
          hIcon = hIconFolders[2];
          break;
      }
      indent = 4 * (1 + LOWORD(lpdis->itemData));
    }

    ExtTextOut(lpdis->hDC, 
               lpdis->rcItem.left + ITEM_LEFTMARGIN + ITEM_BITMAPWIDTH + ITEM_GAP + indent,
               lpdis->rcItem.top,
               ETO_OPAQUE | ETO_CLIPPED,
               &lpdis->rcItem,
               szItem,
               lstrlen(szItem),
               NULL);

    BOOL res = DrawIcon(lpdis->hDC, 
                        lpdis->rcItem.left + ITEM_LEFTMARGIN + indent,
                        lpdis->rcItem.top, 
                        hIcon);

    if(lpdis->itemState & ODS_SELECTED) 
    {
      SetTextColor(lpdis->hDC, colorText);
      SetBkColor(lpdis->hDC, colorBack);
    }
  }
  if((lpdis->itemAction & ODA_FOCUS) || (lpdis->itemState & ODS_FOCUS))
    DrawFocusRect(lpdis->hDC, &lpdis->rcItem);
}
Example #5
0
void PictureButton::DrawItem(LPDRAWITEMSTRUCT dis)
{
	UINT state = DFCS_BUTTONPUSH;
	int style = GetWindowStyle(_hwnd);

	if (dis->itemState & ODS_DISABLED)
		state |= DFCS_INACTIVE;

	POINT imagePos;
	RECT textRect;
	int dt_flags;

	if (style & BS_BOTTOM) {
		 // align horizontal centered, vertical floating
		imagePos.x = (dis->rcItem.left + dis->rcItem.right - _cx) / 2;
		imagePos.y = dis->rcItem.top + 3;

		textRect.left = dis->rcItem.left + 2;
		textRect.top = dis->rcItem.top + _cy + 4;
		textRect.right = dis->rcItem.right - 4;
		textRect.bottom = dis->rcItem.bottom - 4;

		dt_flags = DT_SINGLELINE|DT_CENTER|DT_VCENTER;
	} else {
		 // horizontal floating, vertical centered
		imagePos.x = dis->rcItem.left + 3;
		imagePos.y = (dis->rcItem.top + dis->rcItem.bottom - _cy)/2;

		textRect.left = dis->rcItem.left + _cx + 4;
		textRect.top = dis->rcItem.top + 2;
		textRect.right = dis->rcItem.right - 4;
		textRect.bottom = dis->rcItem.bottom - 4;

		dt_flags = DT_SINGLELINE|DT_VCENTER/*|DT_CENTER*/;
	}

	if (dis->itemState & ODS_SELECTED) {
		state |= DFCS_PUSHED;
		++imagePos.x;		++imagePos.y;
		++textRect.left;	++textRect.top;
		++textRect.right;	++textRect.bottom;
	}

	if (_flat) {
		FillRect(dis->hDC, &dis->rcItem, _hBrush);

		if (style & BS_FLAT)	// Only with BS_FLAT set, there will be drawn a frame without highlight.
			DrawEdge(dis->hDC, &dis->rcItem, EDGE_RAISED, BF_RECT|BF_FLAT);
	} else
		DrawFrameControl(dis->hDC, &dis->rcItem, DFC_BUTTON, state);

	if (_hIcon)
		DrawIconEx(dis->hDC, imagePos.x, imagePos.y, _hIcon, _cx, _cy, 0, _hBrush, DI_NORMAL);
	else {
		MemCanvas mem_dc;
		BitmapSelection sel(mem_dc, _hBmp);
		BitBlt(dis->hDC, imagePos.x, imagePos.y, _cx, _cy, mem_dc, 0, 0, SRCCOPY);
	}

	TCHAR title[BUFFER_LEN];
	GetWindowText(_hwnd, title, BUFFER_LEN);

	BkMode bk_mode(dis->hDC, TRANSPARENT);

	if (dis->itemState & (ODS_DISABLED|ODS_GRAYED))
		DrawGrayText(dis->hDC, &textRect, title, dt_flags);
	else {
		TextColor lcColor(dis->hDC, GetSysColor(COLOR_BTNTEXT));
		DrawText(dis->hDC, title, -1, &textRect, dt_flags);
	}

	if (dis->itemState & ODS_FOCUS) {
		RECT rect = {
			dis->rcItem.left+3, dis->rcItem.top+3,
			dis->rcItem.right-dis->rcItem.left-4, dis->rcItem.bottom-dis->rcItem.top-4
		};
		if (dis->itemState & ODS_SELECTED) {
			++rect.left;	++rect.top;
			++rect.right;	++rect.bottom;
		}
		DrawFocusRect(dis->hDC, &rect);
	}
}
Example #6
0
//--------------------------------------------------------------------------//
//--------------------------------------------------------------------------//
LRESULT CCtlPanel::OnDrawItem(UINT /*uMsg*/, WPARAM wParam,
							   LPARAM lParam, BOOL &bHandled)
{
	UINT idCtl = wParam;
	LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT) lParam;

	if (idCtl == IDC_COLOR)
	{
		CAGDC dc(lpdis->hDC);
		HBRUSH hbr = (HBRUSH) GetStockObject(WHITE_BRUSH);
		FillRect(lpdis->hDC, &lpdis->rcItem, hbr);

		if ((int) lpdis->itemID != -1)
		{
			COLORREF clr = (COLORREF) ::SendMessage(lpdis->hwndItem,
			  CB_GETITEMDATA, lpdis->itemID, 0);

			RECT rect = lpdis->rcItem;
			InflateRect(&rect, -4, -2);
			hbr = CreateSolidBrush(clr | PALETTERGB_FLAG);
			FillRect(lpdis->hDC, &rect, hbr);
			DeleteObject(hbr);
			hbr = (HBRUSH) GetStockObject(BLACK_BRUSH);
			FrameRect(lpdis->hDC, &rect, hbr);
		}

		if (lpdis->itemState & ODS_FOCUS || lpdis->itemState & ODS_SELECTED)
		{
			hbr = (HBRUSH) GetStockObject(BLACK_BRUSH);
			FrameRect(lpdis->hDC, &lpdis->rcItem, hbr);
		}
	}
	else if (idCtl == IDC_FONT)
	{
		if ((int) lpdis->itemID != -1)
		{
			int nFont = ::SendMessage(lpdis->hwndItem, CB_GETITEMDATA, lpdis->itemID, 0);

			FONTARRAY &FontArray = GetFontArray();
			LOGFONT NewFont = FontArray[nFont].lf;
			NewFont.lfHeight = m_nFontHeight;
			NewFont.lfWidth = 0;
			if (NewFont.lfCharSet == SYMBOL_CHARSET)
			{
				lstrcpy(NewFont.lfFaceName, "Arial");
				NewFont.lfCharSet = ANSI_CHARSET;
				NewFont.lfPitchAndFamily = FF_SWISS;
			}

			SaveDC(lpdis->hDC);
			SetTextAlign(lpdis->hDC, TA_LEFT | TA_TOP | TA_NOUPDATECP);

			if (lpdis->itemState & ODS_SELECTED)
				SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
			else
				SetTextColor(lpdis->hDC, GetSysColor(COLOR_WINDOWTEXT));

			if (lpdis->itemState & ODS_SELECTED)
				SetBkColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
			else
				SetBkColor(lpdis->hDC, GetSysColor(COLOR_WINDOW));

			HFONT hFont = CreateFontIndirect(&NewFont);
			HFONT hOldFont = (HFONT) SelectObject(lpdis->hDC, hFont);
			ExtTextOut(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
				ETO_CLIPPED | ETO_OPAQUE, &lpdis->rcItem,
				FontArray[nFont].szFullName,
				lstrlen(FontArray[nFont].szFullName), NULL);
  
			if (lpdis->itemState & ODS_FOCUS)
				DrawFocusRect(lpdis->hDC, &lpdis->rcItem);

			SelectObject(lpdis->hDC, hOldFont);
			DeleteObject(hFont);
			RestoreDC(lpdis->hDC, -1);
		}
	}

	bHandled = TRUE;
	return (TRUE);
}
Example #7
0
LRESULT CALLBACK MainWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch(uMsg)
	{
		// Initialize our window and create our child controls.
	case WM_CREATE:
		{
			hwnd = hWnd;

			HWND hWndChild;

			CenterWindow(hWnd, NULL);

			// Create the info text at the the top.
			hWndChild = CreateWindowEx(0, WC_STATIC, TEXT("RakSAMP " RAKSAMP_VERSION),
				SS_LEFT | WS_CHILD | WS_VISIBLE,
				0, 0, 0, 0, hWnd, (HMENU)(IDC_LBLINFO), g_hInst, NULL);
			if(!hWndChild) return -1;
			SendMessage(hWndChild, WM_SETFONT, (WPARAM)g_hfText, FALSE);
			texthwnd = hWndChild;

			// Create the custom/owner drawn listbox
			hWndChild = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTBOX, NULL, 
				LBS_NOINTEGRALHEIGHT | LBS_OWNERDRAWFIXED | LBS_EXTENDEDSEL |
				WS_VSCROLL | WS_CHILD | WS_TABSTOP | WS_VISIBLE,
				0, 0, 0, 0, hWnd, (HMENU)(IDC_LSTCUSTOM), g_hInst, NULL);
			if(!hWndChild) return -1;
			SendMessage(hWndChild, WM_SETFONT, (WPARAM)g_hfText, FALSE);
			loghwnd = hWndChild;

			// Create the input box.
			hWndChild = CreateWindowEx(0, WC_EDIT, NULL,
				WS_CHILD | WS_TABSTOP | WS_VISIBLE | WS_BORDER,
				0, 0, 0, 0, hWnd, (HMENU)IDC_INPUTBOX, g_hInst, NULL);
			if(!hWndChild) return -1;
			SendMessage(hWndChild, WM_SETFONT, (WPARAM)g_hfText, FALSE);
			inputhwnd = hWndChild;

			// Create the send button.
			hWndChild = CreateWindowEx(0, WC_BUTTON, TEXT("&Send"),
				BS_DEFPUSHBUTTON | BS_TEXT | WS_CHILD | WS_TABSTOP | WS_VISIBLE,
				0, 0, 0, 0, hWnd, (HMENU)IDCANCEL, g_hInst, NULL);
			if(!hWndChild) return -1;
			SendMessage(hWndChild, WM_SETFONT, (WPARAM)g_hfText, FALSE);

			HICON hIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_MAIN));
			SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
			SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);

			SetFocus(inputhwnd);
		}
		return 0;

		// This message is sent for each owner drawn child and only once for LBS_OWNERDRAWFIXED.
		// If we had used LBS_OWNERDRAWVARIABLE it is sent for each item.
	case WM_MEASUREITEM:
		{
			LPMEASUREITEMSTRUCT lpMeasureItem = (LPMEASUREITEMSTRUCT)lParam;
			// Is this measure request for our control?
			if(lpMeasureItem->CtlID == IDC_LSTCUSTOM)
			{
				TEXTMETRIC tm;
				HWND hWndItem = GetDlgItem(hWnd, IDC_LSTCUSTOM);
				HDC  hdcItem  = GetDC(hWndItem);

				if(GetTextMetrics(hdcItem, &tm))
					// Set the item height to that of the font + 10px padding
					lpMeasureItem->itemHeight = tm.tmInternalLeading + 
					tm.tmHeight + tm.tmExternalLeading + 10;

				ReleaseDC(hWndItem, hdcItem);
				return TRUE;
			}
		}
		break;

		// This message is sent for each owner drawn child when it needs to be rendered.
	case WM_DRAWITEM:
		{
			LPDRAWITEMSTRUCT lpDrawItem = (LPDRAWITEMSTRUCT)lParam;
			// Is this draw request for our control?
			if(lpDrawItem->CtlID == IDC_LSTCUSTOM)
			{
				// Get the text pointer
				LPTSTR lpText = (LPTSTR)lpDrawItem->itemData;
				COLORREF textColor = RGB(0, 0, 0);
				COLORREF bkColor = RGB(255, 255, 255);

				if(!strncmp(lpText, "[CHAT] ", 7))
					textColor = RGB(settings.bChatColorRed, settings.bChatColorGreen, settings.bChatColorBlue);

				if(!strncmp(lpText, "[CMSG] ", 7))
					textColor = RGB(settings.bCMsgRed, settings.bCMsgGreen, settings.bCMsgBlue);

				if(settings.iFind)
				{
					for(int i = 0; i < MAX_FIND_ITEMS; i++)
					{
						if(!settings.findItems[i].iExists)
							continue;

						if(strstr(lpText, settings.findItems[i].szFind))
						{
							textColor = RGB(settings.findItems[i].bTextRed,
								settings.findItems[i].bTextGreen,
								settings.findItems[i].bTextBlue);
							bkColor = RGB(settings.findItems[i].bBkRed,
								settings.findItems[i].bBkGreen,
								settings.findItems[i].bBkBlue);
						}
					}
				}

				// Set colors based on selected state
				if(lpDrawItem->itemState & ODS_SELECTED)
				{
					SetBkColor(lpDrawItem->hDC, RGB(230, 255, 255));
					SetTextColor(lpDrawItem->hDC, textColor);
				}
				else
				{
					SetBkColor(lpDrawItem->hDC, bkColor);
					SetTextColor(lpDrawItem->hDC, textColor);
				}

				// Draw the text and fill in the background at the same time
				//  with 5px offset for padding
				ExtTextOut(lpDrawItem->hDC,
					lpDrawItem->rcItem.left + 5, lpDrawItem->rcItem.top + 5,
					ETO_OPAQUE | ETO_CLIPPED, &lpDrawItem->rcItem,
					lpText, lstrlen(lpText), NULL);

				// If this item has the focus add the focus rect
				if(lpDrawItem->itemState & ODS_FOCUS)
					DrawFocusRect(lpDrawItem->hDC, &lpDrawItem->rcItem);

				return TRUE;
			}
		}
		break;

		// This message is sent for each item deleted from an owner drawn control so that 
		//  you can perform custom clean up.
	case WM_DELETEITEM:
		{
			LPDELETEITEMSTRUCT lpDeleteItem = (LPDELETEITEMSTRUCT)lParam;
			// Is this delete request for our control?
			if(lpDeleteItem->CtlID == IDC_LSTCUSTOM)
			{
				delete (LPTSTR)lpDeleteItem->itemData;
				return TRUE;
			}
		}
		break;

		// We accept this message so we can set a minimum window size. This only sets the users
		// tracking size. The window itself can always be resized smaller programmatically unless
		// you restrict it in WM_WINDOWPOSCHANGING/WM_WINDOWPOSCHANGED. 
	case WM_GETMINMAXINFO:
		{
			LPMINMAXINFO lpInfo = (LPMINMAXINFO)lParam;
			if(lpInfo)
				lpInfo->ptMinTrackSize.x = 250, lpInfo->ptMinTrackSize.y = 300;
		}
		return 0;

		// These next two messages are better to use rather than WM_MOVE/WM_SIZE.
		// Remember WM_MOVE/WM_SIZE are from 16bit windows. In 32bit windows the window
		// manager only sends these two messages and the DefWindowProc() handler actually
		// accepts them and converts them to WM_MOVE/WM_SIZE.
		// 
		// We accept this so we can scale our controls to the client size.
	case WM_WINDOWPOSCHANGING:
	case WM_WINDOWPOSCHANGED:
		{
			HDWP hDWP;
			RECT rc;

			// Create a deferred window handle.
			if(hDWP = BeginDeferWindowPos(4))
			{
				// Deferring 4 child controls
				GetClientRect(hWnd, &rc);

				// Calculate the size needed for the static text at the top
				RECT rcText = { 10, 10, rc.right - 20, 0 } ;
				CalcWindowTextSize(GetDlgItem(hWnd, IDC_LBLINFO), &rcText);

				// Defer each window move/size until end and do them all at once.
				hDWP = DeferWindowPos(hDWP, GetDlgItem(hWnd, IDC_LBLINFO), NULL,
					10, 10, rc.right - 20, rcText.bottom,
					SWP_NOZORDER | SWP_NOREDRAW);

				// Move/Size the listbox
				hDWP = DeferWindowPos(hDWP, GetDlgItem(hWnd, IDC_LSTCUSTOM), NULL,
					10, rcText.bottom + 20, rc.right - 20, rc.bottom - rcText.bottom - 75,
					SWP_NOZORDER | SWP_NOREDRAW);

				// Move/Size the input box
				hDWP = DeferWindowPos(hDWP, GetDlgItem(hWnd, IDC_INPUTBOX), NULL,
					10, rc.bottom - 40, rc.right - 90, 30,
					SWP_NOZORDER | SWP_NOREDRAW);

				// Move/Size the send button
				hDWP = DeferWindowPos(hDWP, GetDlgItem(hWnd, IDCANCEL), NULL,
					(rc.right) - 70, rc.bottom - 40, 60, 30,
					SWP_NOZORDER | SWP_NOREDRAW);

				// Resize all windows under the deferred window handled at the same time.
				EndDeferWindowPos(hDWP);

				// We told DeferWindowPos not to redraw the controls so we can redraw
				// them here all at once.
				RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN | 
					RDW_ERASE | RDW_NOFRAME | RDW_UPDATENOW);
			}
		}
		return 0;

		// Handle the notifications of button presses.
	case WM_COMMAND:
		// If it was a button press and it came from our button.
		if(wParam == MAKELONG(IDCANCEL, BN_CLICKED) ||
			(GetFocus() == inputhwnd) && (0x8000 & GetKeyState(VK_RETURN)))
		{
			// process typed command
			if(GetWindowTextLength(inputhwnd) == 0)
				break;

			char str[512];
			SendMessage(inputhwnd, WM_GETTEXT, (WPARAM)512, (LPARAM)str);
			SendMessage(inputhwnd, WM_SETTEXT, 0, (LPARAM)"");
			RunCommand(str, 0);

			SetFocus(inputhwnd);
		}
		else if(HIWORD(wParam) == LBN_DBLCLK)
		{

		}
		break;

	case WM_DESTROY:
		// We post a WM_QUIT when our window is destroyed so we break the main message loop.
		sampDisconnect(0);
		PostQuitMessage(0);
		break;

	}

	// Not a message we wanted? No problem hand it over to the Default Window Procedure.
	return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
Example #8
0
BOOL CALLBACK cfgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  switch (uMsg)
  {
    HANDLE_MSG(hwndDlg, WM_COMMAND, WMCommandProc);
    case WM_DRAWITEM:
    {
      DRAWITEMSTRUCT* lpdis = (DRAWITEMSTRUCT*)lParam;
      int nIdx = FindControlIdx(lpdis->CtlID);
#ifdef IO_LINK_UNDERLINED
      HFONT OldFont;
      LOGFONT lf;
#endif

      if (nIdx < 0)
        break;
      FieldType *pField = pFields + nIdx;

#ifdef IO_LINK_UNDERLINED
      GetObject(GetCurrentObject(lpdis->hDC, OBJ_FONT), sizeof(lf), &lf);
      lf.lfUnderline = TRUE;
      OldFont = (HFONT)SelectObject(lpdis->hDC, CreateFontIndirect(&lf));
#endif

      // We need lpdis->rcItem later
      RECT rc = lpdis->rcItem;

      // Calculate needed size of the control
      DrawText(lpdis->hDC, pField->pszText, -1, &rc, DT_VCENTER | DT_SINGLELINE | DT_CALCRECT);

      // Make some more room so the focus rect won't cut letters off
      rc.right = min(rc.right + 2, lpdis->rcItem.right);

      // Move rect to right if in RTL mode
      if (bRTL)
      {
        rc.left += lpdis->rcItem.right - rc.right;
        rc.right += lpdis->rcItem.right - rc.right;
      }

      if (lpdis->itemAction & ODA_DRAWENTIRE)
      {
        // Get TxtColor unless the user has set another using SetCtlColors
        if (!GetWindowLong(lpdis->hwndItem, GWL_USERDATA))
          SetTextColor(lpdis->hDC, (COLORREF) pField->hImage);

        // Draw the text
        DrawText(lpdis->hDC, pField->pszText, -1, &rc, DT_CENTER | DT_VCENTER | DT_SINGLELINE | (bRTL ? DT_RTLREADING : 0));
      }

      // Draw the focus rect if needed
      if (((lpdis->itemState & ODS_FOCUS) && (lpdis->itemAction & ODA_DRAWENTIRE)) || (lpdis->itemAction & ODA_FOCUS))
      {
        // NB: when not in DRAWENTIRE mode, this will actually toggle the focus
        // rectangle since it's drawn in a XOR way
        DrawFocusRect(lpdis->hDC, &rc);
      }

      pField->rect = rc;

#ifdef IO_LINK_UNDERLINED
      DeleteObject(SelectObject(lpdis->hDC, OldFont));
#endif
      break;
    }
    case WM_CTLCOLORSTATIC:
    case WM_CTLCOLOREDIT:
    case WM_CTLCOLORDLG:
    case WM_CTLCOLORBTN:
    case WM_CTLCOLORLISTBOX:
      // let the NSIS window handle colors, it knows best
      return mySendMessage(hMainWindow, uMsg, wParam, lParam);
  }
  return 0;
}
Example #9
0
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  switch (uMsg)
  {
    // handle notifications
    case WM_COMMAND:
    {
      HWND hwCtl = GetDlgItem(hwndDlg, LOWORD(wParam));
      struct nsControl* ctl = GetControl(hwCtl);

      if (ctl == NULL)
        break;

      if (HIWORD(wParam) == BN_CLICKED && ctl->type == NSCTL_BUTTON)
      {
        if (ctl->callbacks.onClick)
        {
          pushint((int) hwCtl);
          g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onClick - 1, 0);
        }
      }
      else if (HIWORD(wParam) == EN_CHANGE && ctl->type == NSCTL_EDIT)
      {
        if (ctl->callbacks.onChange)
        {
          pushint((int) hwCtl);
          g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
        }
      }
      else if (HIWORD(wParam) == LBN_SELCHANGE && ctl->type == NSCTL_LISTBOX)
      {
        if (ctl->callbacks.onChange)
        {
          pushint((int) hwCtl);
          g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
        }
      }
      else if ((HIWORD(wParam) == CBN_EDITUPDATE || HIWORD(wParam) == CBN_SELCHANGE)
                && ctl->type == NSCTL_COMBOBOX)
      {
        if (ctl->callbacks.onChange)
        {
          pushint((int) hwCtl);
          g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
        }
      }
      else if (HIWORD(wParam) == STN_CLICKED && ctl->type == NSCTL_STATIC)
      {
        if (ctl->callbacks.onClick)
        {
          pushint((int) hwCtl);
          g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onClick - 1, 0);
        }
      }

      break;
    }

    case WM_NOTIFY:
    {
      LPNMHDR nmhdr = (LPNMHDR) lParam;
      struct nsControl* ctl = GetControl(nmhdr->hwndFrom);

      if (ctl == NULL)
        break;

      if (!ctl->callbacks.onNotify)
        break;

      pushint((int) nmhdr);
      pushint(nmhdr->code);
      pushint((int) nmhdr->hwndFrom);
      g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onNotify - 1, 0);
    }

    // handle links
    case WM_DRAWITEM:
    {
      DRAWITEMSTRUCT* lpdis = (DRAWITEMSTRUCT*)lParam;
      RECT rc;
      char text[1024];

      // http://blogs.msdn.com/oldnewthing/archive/2005/05/03/414317.aspx#414357
      // says we should call SystemParametersInfo(SPI_GETKEYBOARDCUES,...) to make
      // sure, does not seem to be required, might be a win2k bug, or it might
      // only apply to menus
      BOOL hideFocus = (lpdis->itemState & ODS_NOFOCUSRECT);
      BOOL hideAccel = (lpdis->itemState & ODS_NOACCEL);

      struct nsControl* ctl = GetControl(lpdis->hwndItem);
      if (ctl == NULL)
        break;

      // We need lpdis->rcItem later
      rc = lpdis->rcItem;

      // Get button's text
      text[0] = '\0';
      GetWindowText(lpdis->hwndItem, text, 1024);

      // Calculate needed size of the control
      DrawText(lpdis->hDC, text, -1, &rc, DT_VCENTER | DT_WORDBREAK | DT_CALCRECT);

      // Make some more room so the focus rect won't cut letters off
      rc.right = min(rc.right + 2, lpdis->rcItem.right);

      // Move rect to right if in RTL mode
      if (g_dialog.rtl)
      {
        rc.left += lpdis->rcItem.right - rc.right;
        rc.right += lpdis->rcItem.right - rc.right;
      }

      if (lpdis->itemAction & ODA_DRAWENTIRE)
      {
        DWORD xtraDrawStyle = (g_dialog.rtl ? DT_RTLREADING : 0);
        if (hideAccel)
          xtraDrawStyle |= DT_HIDEPREFIX;

        // Use blue unless the user has set another using SetCtlColors
        if (!GetWindowLong(lpdis->hwndItem, GWL_USERDATA))
          SetTextColor(lpdis->hDC, RGB(0,0,255));

        // Draw the text
        DrawText(lpdis->hDC, text, -1, &rc, xtraDrawStyle | DT_CENTER | DT_VCENTER | DT_WORDBREAK);
      }

      // Draw the focus rect if needed
      if (((lpdis->itemState & ODS_FOCUS) && (lpdis->itemAction & ODA_DRAWENTIRE)) || (lpdis->itemAction & ODA_FOCUS))
      {
        // NB: when not in DRAWENTIRE mode, this will actually toggle the focus
        // rectangle since it's drawn in a XOR way
        if (!hideFocus)
          DrawFocusRect(lpdis->hDC, &rc);
      }

      return TRUE;
    }

    // handle colors
    case WM_CTLCOLORSTATIC:
    case WM_CTLCOLOREDIT:
    case WM_CTLCOLORDLG:
    case WM_CTLCOLORBTN:
    case WM_CTLCOLORLISTBOX:
      // let the NSIS window handle colors, it knows best
      return SendMessage(g_dialog.hwParent, uMsg, wParam, lParam);
  }

  return FALSE;
}
Example #10
0
void Picker_HandleDrawItem(HWND hWnd, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	struct PickerInfo *pPickerInfo;
	HDC         hDC = lpDrawItemStruct->hDC;
	RECT        rcItem = lpDrawItemStruct->rcItem;
	UINT        uiFlags = ILD_TRANSPARENT;
	HIMAGELIST  hImageList;
	int         nItem = lpDrawItemStruct->itemID;
	COLORREF    clrTextSave = 0;
	COLORREF    clrBkSave = 0;
	COLORREF    clrImage = GetSysColor(COLOR_WINDOW);
	static TCHAR szBuff[MAX_PATH];
	BOOL        bFocus = (GetFocus() == hWnd);
	LPCTSTR     pszText;
	UINT        nStateImageMask = 0;
	BOOL        bSelected = 0;
	LV_COLUMN   lvc;
	LV_ITEM     lvi;
	RECT        rcAllLabels;
	RECT        rcLabel;
	RECT        rcIcon;
	int         offset = 0;
	SIZE        size;
	int         i = 0, j = 0;
	int         nColumn = 0;
	int         nColumnMax = 0;
	int         *order;
	BOOL        bDrawAsChild = 0;
	int indent_space = 0;
	BOOL		bColorChild = FALSE;
	BOOL		bParentFound = FALSE;
	int		nParent = 0;
	HBITMAP		hBackground = GetBackgroundBitmap();
	MYBITMAPINFO *pbmDesc = GetBackgroundInfo();
	BOOL res = 0;

	pPickerInfo = GetPickerInfo(hWnd);

	order = (int*)malloc(pPickerInfo->nColumnCount * sizeof(*order));
	if (!order)
		return;
	nColumnMax = Picker_GetNumColumns(hWnd);

	if (GetUseOldControl())
	{
		pPickerInfo->pCallbacks->pfnGetColumnOrder(order);
	}
	else
	{
		/* Get the Column Order and save it */
		res = ListView_GetColumnOrderArray(hWnd, nColumnMax, order);

		/* Disallow moving column 0 */
		if (order[0] != 0)
		{
			for (i = 0; i < nColumnMax; i++)
			{
				if (order[i] == 0)
				{
					order[i] = order[0];
					order[0] = 0;
				}
			}
			res = ListView_SetColumnOrderArray(hWnd, nColumnMax, order);
		}
	}

	/* Labels are offset by a certain amount */
	/* This offset is related to the width of a space character */
	GetTextExtentPoint32(hDC, TEXT(" "), 1, &size);
	offset = size.cx;

	lvi.mask	   = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_PARAM;
	lvi.iItem	   = nItem;
	lvi.iSubItem   = order[0];
	lvi.pszText	   = szBuff;
	lvi.cchTextMax = sizeof(szBuff) / sizeof(szBuff[0]);
	lvi.stateMask  = 0xFFFF;	   /* get all state flags */
	res = ListView_GetItem(hWnd, &lvi);

	bSelected = ((lvi.state & LVIS_DROPHILITED) || ( (lvi.state & LVIS_SELECTED)
		&& ((bFocus) || (GetWindowLong(hWnd, GWL_STYLE) & LVS_SHOWSELALWAYS))));

	/* figure out if we indent and draw grayed */
	if (pPickerInfo->pCallbacks->pfnFindItemParent)
		nParent = pPickerInfo->pCallbacks->pfnFindItemParent(hWnd, lvi.lParam);
	else
		nParent = -1;
	bDrawAsChild = (pPickerInfo->pCallbacks->pfnGetViewMode() == VIEW_GROUPED && (nParent >= 0));

	/* only indent if parent is also in this view */
	if ((nParent >= 0) && bDrawAsChild)
	{
		for (i = 0; i < ListView_GetItemCount(hWnd); i++)
		{
			lvi.mask = LVIF_PARAM;
			lvi.iItem = i;
			res = ListView_GetItem(hWnd, &lvi);

			if (lvi.lParam == nParent)
			{
				bParentFound = TRUE;
				break;
			}
		}
	}

	if (pPickerInfo->pCallbacks->pfnGetOffsetChildren && pPickerInfo->pCallbacks->pfnGetOffsetChildren())
	{
		if (!bParentFound && bDrawAsChild)
		{
			/*Reset it, as no Parent is there*/
			bDrawAsChild = FALSE;
			bColorChild = TRUE;
		}
		else
		{
			nParent = -1;
			bParentFound = FALSE;
		}
	}

	res = ListView_GetItemRect_Modified(hWnd, nItem, &rcAllLabels, LVIR_BOUNDS);
	res = ListView_GetItemRect_Modified(hWnd, nItem, &rcLabel, LVIR_LABEL);

	rcAllLabels.left = rcLabel.left;

	if (hBackground != NULL)
	{
		RECT		rcClient;
		HRGN		rgnBitmap;
		RECT		rcTmpBmp = rcItem;
		RECT		rcFirstItem;
		HPALETTE	hPAL;
		HDC 		htempDC;
		HBITMAP 	oldBitmap;

		htempDC = CreateCompatibleDC(hDC);

		oldBitmap = (HBITMAP)SelectObject(htempDC, hBackground);

		GetClientRect(hWnd, &rcClient);
		rcTmpBmp.right = rcClient.right;
		/* We also need to check whether it is the last item
           The update region has to be extended to the bottom if it is */
		if (nItem == ListView_GetItemCount(hWnd) - 1)
			rcTmpBmp.bottom = rcClient.bottom;

		rgnBitmap = CreateRectRgnIndirect(&rcTmpBmp);
		SelectClipRgn(hDC, rgnBitmap);
		DeleteBitmap(rgnBitmap);

		hPAL = GetBackgroundPalette();
		if (hPAL == NULL)
			hPAL = CreateHalftonePalette(hDC);

		if (GetDeviceCaps(htempDC, RASTERCAPS) & RC_PALETTE && hPAL != NULL)
		{
			SelectPalette(htempDC, hPAL, FALSE);
			RealizePalette(htempDC);
		}

		res = ListView_GetItemRect_Modified(hWnd, 0, &rcFirstItem, LVIR_BOUNDS);

		for (i = rcFirstItem.left; i < rcClient.right; i += pbmDesc->bmWidth)
			for (j = rcFirstItem.top; j < rcClient.bottom; j +=  pbmDesc->bmHeight)
				BitBlt(hDC, i, j, pbmDesc->bmWidth, pbmDesc->bmHeight, htempDC, 0, 0, SRCCOPY);

		SelectObject(htempDC, oldBitmap);
		DeleteDC(htempDC);

		if (GetBackgroundPalette() == NULL)
		{
			DeletePalette(hPAL);
			hPAL = NULL;
		}
	}

	indent_space = 0;

	if (bDrawAsChild)
	{
		RECT rect;

		res = ListView_GetItemRect_Modified(hWnd, nItem, &rect, LVIR_ICON);

		/* indent width of icon + the space between the icon and text
         * so left of clone icon starts at text of parent
         */
		indent_space = rect.right - rect.left + offset;
	}

	rcAllLabels.left += indent_space;

	if (bSelected)
	{
		HBRUSH hBrush;
		HBRUSH hOldBrush;

		if (bFocus)
		{
			clrTextSave = SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
			clrBkSave	= SetBkColor(hDC, GetSysColor(COLOR_HIGHLIGHT));
			hBrush		= CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
		}
		else
		{
			clrTextSave = SetTextColor(hDC, GetSysColor(COLOR_BTNTEXT));
			clrBkSave	= SetBkColor(hDC, GetSysColor(COLOR_BTNFACE));
			hBrush		= CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
		}

		hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);
		FillRect(hDC, &rcAllLabels, hBrush);
		SelectObject(hDC, hOldBrush);
		DeleteBrush(hBrush);
	}
	else
	{
		if (hBackground == NULL)
		{
			HBRUSH hBrush;

			hBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
			FillRect(hDC, &rcAllLabels, hBrush);
			DeleteBrush(hBrush);
		}

		if (pPickerInfo->pCallbacks->pfnGetOffsetChildren && pPickerInfo->pCallbacks->pfnGetOffsetChildren())
		{
			if (bDrawAsChild || bColorChild)
				clrTextSave = SetTextColor(hDC, GetListCloneColor());
			else
				clrTextSave = SetTextColor(hDC, GetListFontColor());
		}
		else
		{
			if (bDrawAsChild)
				clrTextSave = SetTextColor(hDC, GetListCloneColor());
			else
				clrTextSave = SetTextColor(hDC, GetListFontColor());
		}

		clrBkSave = SetBkColor(hDC, GetSysColor(COLOR_WINDOW));
	}


	if (lvi.state & LVIS_CUT)
	{
		clrImage = GetSysColor(COLOR_WINDOW);
		uiFlags |= ILD_BLEND50;
	}
	else if (bSelected)
	{
		if (bFocus)
			clrImage = GetSysColor(COLOR_HIGHLIGHT);
		else
			clrImage = GetSysColor(COLOR_BTNFACE);

		uiFlags |= ILD_BLEND50;
	}

	nStateImageMask = lvi.state & LVIS_STATEIMAGEMASK;

	if (nStateImageMask)
	{
		int nImage = (nStateImageMask >> 12) - 1;
		hImageList = ListView_GetImageList(hWnd, LVSIL_STATE);
		if (hImageList)
			ImageList_Draw(hImageList, nImage, hDC, rcItem.left, rcItem.top, ILD_TRANSPARENT);
	}

	res = ListView_GetItemRect_Modified(hWnd, nItem, &rcIcon, LVIR_ICON);

	rcIcon.left += indent_space;

	res = ListView_GetItemRect_Modified(hWnd, nItem, &rcItem, LVIR_LABEL);

	hImageList = ListView_GetImageList(hWnd, LVSIL_SMALL);
	if (hImageList)
	{
		UINT nOvlImageMask = lvi.state & LVIS_OVERLAYMASK;
		if (rcIcon.left + 16 + indent_space < rcItem.right)
		{
			ImageList_DrawEx(hImageList, lvi.iImage, hDC, rcIcon.left, rcIcon.top, 16, 16,
				GetSysColor(COLOR_WINDOW), clrImage, uiFlags | nOvlImageMask);
		}
	}

	res = ListView_GetItemRect_Modified(hWnd, nItem, &rcItem, LVIR_LABEL);

	pszText = MakeShortString(hDC, szBuff, rcItem.right - rcItem.left, 2*offset + indent_space);

	rcLabel = rcItem;
	rcLabel.left  += offset + indent_space;
	rcLabel.right -= offset;

	DrawText(hDC, pszText, -1, &rcLabel, DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER);

	for (nColumn = 1; nColumn < nColumnMax; nColumn++)
	{
		int 	nRetLen;
		UINT	nJustify;
		LV_ITEM lvItem;

		lvc.mask = LVCF_FMT | LVCF_WIDTH;
		res = ListView_GetColumn(hWnd, order[nColumn], &lvc);

		lvItem.mask 	  = LVIF_TEXT;
		lvItem.iItem	  = nItem;
		lvItem.iSubItem   = order[nColumn];
		lvItem.pszText	  = szBuff;
		lvItem.cchTextMax = sizeof(szBuff) / sizeof(szBuff[0]);

		if (ListView_GetItem(hWnd, &lvItem) == FALSE)
			continue;

		rcItem.left   = rcItem.right;
		rcItem.right += lvc.cx;

		nRetLen = _tcslen(szBuff);
		if (nRetLen == 0)
			continue;

		pszText = MakeShortString(hDC, szBuff, rcItem.right - rcItem.left, 2 * offset);

		nJustify = DT_LEFT;

		if (pszText == szBuff)
		{
			switch (lvc.fmt & LVCFMT_JUSTIFYMASK)
			{
			case LVCFMT_RIGHT:
				nJustify = DT_RIGHT;
				break;

			case LVCFMT_CENTER:
				nJustify = DT_CENTER;
				break;

			default:
				break;
			}
		}

		rcLabel = rcItem;
		rcLabel.left  += offset;
		rcLabel.right -= offset;
		DrawText(hDC, pszText, -1, &rcLabel,
				 nJustify | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER);
	}

	if (lvi.state & LVIS_FOCUSED && bFocus)
		DrawFocusRect(hDC, &rcAllLabels);

	SetTextColor(hDC, clrTextSave);
	SetBkColor(hDC, clrBkSave);
	free(order);
	res++;
}
Example #11
0
INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    static COLORCHOOSER* pCC = NULL;
    static int iCurrentHotTrack;
    static BOOL bChoosing;
    static int iRows;
    static int iColumns;
    static HWND hPreviousActiveWindow;

    switch(msg) {
    case WM_INITDIALOG:
    {
        RECT rc;
        int iSquareRoot;
        int width ;
        int height;

        TranslateDialogDefault(hwndDlg);
        pCC = (COLORCHOOSER*) lParam;

        iCurrentHotTrack = -2;
        bChoosing = FALSE;

        iSquareRoot = (int)sqrt(pCC->pModule->nColorCount);

        iColumns = iSquareRoot * iSquareRoot == pCC->pModule->nColorCount?iSquareRoot:iSquareRoot+1;
        iRows = iSquareRoot;

        rc.top = rc.left = 100;
        rc.right =  100 +  iColumns * 25 + 1;
        rc.bottom = iRows * 20 + 100 + 20;

        AdjustWindowRectEx(&rc, GetWindowLong(hwndDlg, GWL_STYLE), FALSE, GetWindowLong(hwndDlg, GWL_EXSTYLE));

        width = rc.right - rc.left;
        height = rc.bottom - rc.top;

        pCC->yPosition -= height;


        SetDlgItemText(hwndDlg, IDC_CHAT_COLORTEXT, pCC->bForeground?TranslateT("Text colour"):TranslateT("Background colour"));
        SetWindowPos(GetDlgItem(hwndDlg, IDC_CHAT_COLORTEXT), NULL,  0, 0, width, 20, 0);
        SetWindowPos(hwndDlg, NULL, pCC->xPosition, pCC->yPosition, width, height, SWP_SHOWWINDOW);
    }
    break;

    case WM_CTLCOLOREDIT:
    case WM_CTLCOLORSTATIC:
        if((HWND)lParam==GetDlgItem(hwndDlg,IDC_CHAT_COLORTEXT)) {
            SetTextColor((HDC)wParam,RGB(60,60,150));
            SetBkColor((HDC)wParam,GetSysColor(COLOR_WINDOW));
            return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
        }
        break;

    case WM_COMMAND:
        switch ( LOWORD( wParam )) {
        case IDOK:
            if (iCurrentHotTrack >= 0)
                PostMessage(hwndDlg, WM_LBUTTONUP, 0, 0);
            break;
        case IDCANCEL:
            DestroyWindow(hwndDlg);
            break;
        }
        break;

    case WM_LBUTTONUP:
        if (iCurrentHotTrack >= 0 && iCurrentHotTrack < pCC->pModule->nColorCount && pCC->hWndTarget != NULL) {
            HWND hWindow;
            CHARFORMAT2 cf;
            cf.cbSize = sizeof(CHARFORMAT2);
            cf.dwMask = 0;
            cf.dwEffects = 0;
            hWindow = GetParent(pCC->hWndTarget);

            if ( pCC->bForeground ) {
                pCC->si->bFGSet = TRUE;
                pCC->si->iFG = iCurrentHotTrack;
                if ( IsDlgButtonChecked( hWindow, IDC_CHAT_COLOR )) {
                    cf.dwMask = CFM_COLOR;
                    cf.crTextColor = pCC->pModule->crColors[iCurrentHotTrack];
                    if (pCC->pModule->bSingleFormat) {
                        SendMessage(pCC->hWndTarget, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
                    } else {
                        SendMessage(pCC->hWndTarget, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
                    }
                }
            }
            else {
                pCC->si->bBGSet = TRUE;
                pCC->si->iBG = iCurrentHotTrack;
                if(IsDlgButtonChecked(hWindow, IDC_CHAT_BKGCOLOR)) {
                    cf.dwMask = CFM_BACKCOLOR;
                    cf.crBackColor = pCC->pModule->crColors[iCurrentHotTrack];
                    if (pCC->pModule->bSingleFormat) {
                        SendMessage(pCC->hWndTarget, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
                    } else {
                        SendMessage(pCC->hWndTarget, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
                    }
                }
            }
        }
        PostMessage(hwndDlg, WM_CLOSE, 0, 0);
        break;

    case WM_ACTIVATE:
        if (wParam == WA_INACTIVE)
            PostMessage(hwndDlg, WM_CLOSE, 0, 0);
        else if ((wParam == WA_ACTIVE) || (wParam == WA_CLICKACTIVE))
            hPreviousActiveWindow = (HWND)lParam;
        break;

    case WM_MOUSEMOVE:
    {
        HDC hdc = GetDC(hwndDlg);
        POINT pt;
        RECT rect;
        int but;

        pt.x = LOWORD(lParam);
        pt.y = HIWORD(lParam);

        if (iCurrentHotTrack == -2)
            return 0; // prevent focussing when not drawn yet!

        but = CalculateCoordinatesToButton(pCC, pt);

        // weird stuff
        if (but != iCurrentHotTrack) {
            if (iCurrentHotTrack >= 0) {
                rect = CalculateButtonToCoordinates(pCC, iCurrentHotTrack);
                DrawFocusRect(hdc, &rect);
                iCurrentHotTrack = -1;
            }
            iCurrentHotTrack = but;

            if (iCurrentHotTrack >= 0) {
                rect = CalculateButtonToCoordinates(pCC, iCurrentHotTrack);
                DrawFocusRect(hdc, &rect);
            }
        }
        ReleaseDC(hwndDlg, hdc);
    }
    break;

    case WM_PAINT:
    {
        PAINTSTRUCT ps;
        HDC hdc;
        RECT rc;
        int i;
        int iThisRow = 1;
        int iThisColumn = 0;

        GetClientRect(hwndDlg, &rc);

        rc.top += 20;

        hdc = BeginPaint(hwndDlg, &ps);

        // fill background
        FillRect(hdc, &rc, GetSysColorBrush(COLOR_WINDOW));

        for (i=0; i < pCC->pModule->nColorCount; i++)
        {
            HBRUSH hbr;

            // decide place to draw the color block in the window
            iThisColumn ++;
            if (iThisColumn > iColumns) {
                iThisColumn = 1;
                iThisRow++;
            }

            if ( (pCC->bForeground && pCC->si->bFGSet && pCC->si->iFG == i) ||
                    (!pCC->bForeground && pCC->si->bBGSet && pCC->si->iBG == i) ) {
                rc.top = (iThisRow-1) * 20+ 1 +20 ;
                rc.left = (iThisColumn-1) * 25 + 1 + 1 ;
                rc.bottom = iThisRow * 20- 1 + 20 ;
                rc.right = iThisColumn * 25-1 ;

                DrawEdge(hdc, &rc, EDGE_RAISED, BF_TOP|BF_LEFT|BF_RIGHT|BF_BOTTOM);
            }

            rc.top = (iThisRow-1) * 20+ 3 +20 ;
            rc.left = (iThisColumn-1) * 25 + 3 + 1 ;
            rc.bottom = iThisRow * 20- 3 + 20 ;
            rc.right = iThisColumn * 25-3 ;

            FillRect(hdc, &rc, GetStockObject(BLACK_BRUSH));

            hbr = CreateSolidBrush(pCC->pModule->crColors[i]);

            rc.top = (iThisRow-1) * 20+4 +20;
            rc.left = (iThisColumn-1) * 25+ 4 + 1;
            rc.bottom = iThisRow * 20-4 + 20;
            rc.right = iThisColumn * 25-4;

            FillRect(hdc, &rc, hbr);
            DeleteObject(hbr);
        }

        EndPaint(hwndDlg, &ps);
        iCurrentHotTrack = -1;
    }
    break;

    case WM_CLOSE:
        SetFocus(pCC->hWndTarget);
        DestroyWindow(hwndDlg);
        break;

    case WM_DESTROY:
        mir_free( pCC );
        return TRUE;
    }

    return FALSE;
}
BOOL CALLBACK WindowProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
  switch (Msg)
  {
    case WM_CLOSE:
//  MessageBox(g_window.hwWindow,"WM_CLOSE",NULL,MB_OK);
      if (g_pluginParms->ExecuteCodeSegment(g_window.callbacks.onBack - 1, 0))
      {
        return FALSE;
      }
      else
    {
      //DestroyWindow(g_window.hwWindow);
      DestroyWindow(g_window.hwWindow);
        return FALSE;
    }

    // handle notifications
    case WM_COMMAND:
    {
      HWND hwCtl = GetDlgItem(g_window.hwWindow, LOWORD(wParam));
//      struct s_control sCtl;
//	  ctl = (struct nsControl*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct nsControl));
	  ctl = GetControl(hwCtl);

      if (ctl == NULL)
        break;

      if (HIWORD(wParam) == BN_CLICKED && (ctl->type == NSCTL_BUTTON || ctl->type == NSCTL_LINK))
      {
        if (ctl->callbacks.onClick)
        {
          pushint((int) hwCtl);
          g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onClick - 1, 0);
        }
      }
      else if (HIWORD(wParam) == EN_CHANGE && ctl->type == NSCTL_EDIT)
      {
        if (ctl->callbacks.onChange)
        {
        pushint((int) hwCtl);
        g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
      }
      }
      else if (HIWORD(wParam) == LBN_SELCHANGE && ctl->type == NSCTL_LISTBOX)
      {
        if (ctl->callbacks.onChange)
        {
        pushint((int) hwCtl);
        g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
      }
      }
      else if ((HIWORD(wParam) == CBN_EDITUPDATE || HIWORD(wParam) == CBN_SELCHANGE)
                && ctl->type == NSCTL_COMBOBOX)
      {
        if (ctl->callbacks.onChange)
        {
        pushint((int) hwCtl);
        g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
      }
      }
      else if (HIWORD(wParam) == STN_CLICKED && ctl->type == NSCTL_STATIC)
      {
        if (ctl->callbacks.onClick)
        {
        pushint((int) hwCtl);
        g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onClick - 1, 0);
				}
      }

		  //ctl = NULL;
      break;
    }

    case WM_NOTIFY:
    {
      LPNMHDR nmhdr = (LPNMHDR) lParam;
      //struct nsControl* ctl = GetControl(nmhdr->hwndFrom);
//      struct s_control sCtl;
//	  sCtl.controls = (struct control*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct control));
	  ctl = GetControl(nmhdr->hwndFrom);

      if (ctl == NULL)
        break;

      if (!ctl->callbacks.onNotify)
        break;

      pushint((int) nmhdr);
      pushint(nmhdr->code);
      pushint((int) nmhdr->hwndFrom);
      g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onNotify - 1, 0);
    }

    case WM_DROPFILES:
    {
  // get info from stack

      //HWND hwCtl = (HWND) popint();
      //nsFunction callback = (nsFunction) popint();
      //HWND hwCtl = (HWND) hwnd;
      CHAR szBuf[NSWINDOWS_MAX_STRLEN];
      //LPSTR szStr[256];
      HDROP hDrop = (HDROP)wParam;
			int iCount, index; 

      //if (!IsWindow(hwCtl))
			//	return FALSE;

			if (IsIconic(hwnd))
				ShowWindow(hwnd,SW_RESTORE);
			SetForegroundWindow(hwnd);

			//MessageBox(g_window.hwWindow,"DropFilesWndProc",NULL,MB_OK);
			//DragQueryFile(hDrop,0,szBuf,sizeof(szBuf));
			index = 0xFFFFFFFF;
			iCount = DragQueryFile(hDrop,index,szBuf,sizeof(szBuf));
			for (index = iCount - 1; index >=0; index--)
			{
				DragQueryFile(hDrop,index,szBuf,sizeof(szBuf));
				pushstring(szBuf);
			}
				//pushint((int) hwCtl);
				pushint((int) iCount);

				//MessageBox(g_window.hwWindow,szBuf,NULL,MB_OK);

			g_pluginParms->ExecuteCodeSegment(g_window.callbacks.onDropFiles - 1, 0);
    return FALSE;
  }

	// handle links
    case WM_DRAWITEM:
    {
      DRAWITEMSTRUCT* lpdis = (DRAWITEMSTRUCT*)lParam;
      RECT rc;
      char text[1024];

      // http://blogs.msdn.com/oldnewthing/archive/2005/05/03/414317.aspx#414357
      // says we should call SystemParametersInfo(SPI_GETKEYBOARDCUES,..) to make
      // sure, does not seem to be required, might be a win2k bug, or it might
      // only apply to menus
      BOOL hideFocus = (lpdis->itemState & ODS_NOFOCUSRECT);
      BOOL hideAccel = (lpdis->itemState & ODS_NOACCEL);

      //struct nsControl* ctl = GetControl(lpdis->hwndItem);
//      struct s_control sCtl;
//	  sCtl.controls = (struct control*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct control));
//	  ctl = (struct nsControl*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct nsControl));
	  ctl = GetControl(lpdis->hwndItem);

      if (ctl == NULL)
        break;

      // We need lpdis->rcItem later
      rc = lpdis->rcItem;

      // Get button's text
      text[0] = '\0';
      GetWindowText(lpdis->hwndItem, text, 1024);

      // Calculate needed size of the control
      DrawText(lpdis->hDC, text, -1, &rc, DT_VCENTER | DT_WORDBREAK | DT_CALCRECT);

      // Make some more room so the focus rect won't cut letters off
      rc.right = min(rc.right + 2, lpdis->rcItem.right);

      // Move rect to right if in RTL mode
      if (g_window.rtl)
      {
        rc.left += lpdis->rcItem.right - rc.right;
        rc.right += lpdis->rcItem.right - rc.right;
      }

      if (lpdis->itemAction & ODA_DRAWENTIRE)
      {
        DWORD xtraDrawStyle = (g_window.rtl ? DT_RTLREADING : 0);
        if (hideAccel)
          xtraDrawStyle |= DT_HIDEPREFIX;

        // Use blue unless the user has set another using SetCtlColors
        if (!GetWindowLong(lpdis->hwndItem, GWL_USERDATA))
          SetTextColor(lpdis->hDC, RGB(0,0,255));

        // Draw the text
        DrawText(lpdis->hDC, text, -1, &rc, xtraDrawStyle | DT_CENTER | DT_VCENTER | DT_WORDBREAK);
      }

      // Draw the focus rect if needed
      if (((lpdis->itemState & ODS_FOCUS) && (lpdis->itemAction & ODA_DRAWENTIRE)) || (lpdis->itemAction & ODA_FOCUS))
      {
        // NB: when not in DRAWENTIRE mode, this will actually toggle the focus
        // rectangle since it's drawn in a XOR way
        if (!hideFocus)
          DrawFocusRect(lpdis->hDC, &rc);
      }

      return TRUE;
    }

    // handle colors
    case WM_CTLCOLORSTATIC:
    case WM_CTLCOLOREDIT:
    case WM_CTLCOLORDLG:
    case WM_CTLCOLORBTN:
    case WM_CTLCOLORLISTBOX:
      // let the NSIS window handle colors, it knows best
      return SendMessage(g_window.hwParent, Msg, wParam, lParam);

    // bye bye
    case WM_DESTROY:
    {
      unsigned i;
      for (i = 0; i < g_window.controlCount; i++)
      {
        RemoveProp(g_window.controls[i].window, NSCONTROL_ID_PROP);
      }
	  PostQuitMessage(0);
    break;
    }
  } 
  return FALSE;
}
Example #13
0
void Cls_OnTraysDrawItem(HWND hwnd, const DRAWITEMSTRUCT * lpDrawItem)
{
	HDC		hdc = lpDrawItem->hDC;
	HBRUSH	hBrush;
	RECT	rRect = lpDrawItem->rcItem,
			rIcon = lpDrawItem->rcItem;
	int		itemHeight = rRect.bottom - rRect.top;

	if (lpDrawItem->itemAction & (ODA_DRAWENTIRE | ODA_FOCUS))
	{
		if (hBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW)))
		{
			FrameRect(hdc, &rRect, hBrush);
			DeleteObject(hBrush);
		}

		if (lpDrawItem->itemState & ODS_FOCUS)
		{
			DrawFocusRect(hdc, &rRect);
		}
	}

	InflateRect(&rRect, -1, -1);

	if (lpDrawItem->itemAction & ODA_DRAWENTIRE)
	{
		rIcon.right = rIcon.left + itemHeight;
		InflateRect(&rIcon, -2, -2);

		switch (lpDrawItem->CtlID)
		{
		  case IDC_DEF_PAPER_SIZE:
		  case IDC_MEDIA_SIZE1:
		  case IDC_MEDIA_SIZE2:
		  case IDC_MEDIA_SIZE3:
		  case IDC_MEDIA_SIZE5:
		  {
			HICON hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(media_size[(int)lpDrawItem->itemData].uMediaSizeIconID));
			DrawIcon(hdc, rIcon.left, rIcon.top, hIcon);
			DestroyIcon(hIcon);
		  	break;
		  }

		}
	}

	rRect.left = itemHeight;

	if (lpDrawItem->itemAction & (ODA_DRAWENTIRE | ODA_SELECT))
	{
		LPTSTR lpszPtr;

		switch (lpDrawItem->CtlID)
		{
		  case IDC_DEF_PAPER_SIZE:
		  case IDC_MEDIA_SIZE1:
		  case IDC_MEDIA_SIZE2:
		  case IDC_MEDIA_SIZE3:
		  case IDC_MEDIA_SIZE5:
		  	lpszPtr = media_size[(int)lpDrawItem->itemData].szMediaSize;
		  	break;

		  default:
		  	lpszPtr = TEXT("");
		}

		if (hBrush = CreateSolidBrush(GetSysColor((lpDrawItem->itemState & ODS_SELECTED) ? COLOR_HIGHLIGHT : COLOR_WINDOW)))
		{
			FillRect(hdc, &rRect, hBrush);
			DeleteObject(hBrush);
		}		

		rRect.left += 2;
		SetBkMode(hdc, TRANSPARENT);
		SetTextColor(hdc, GetSysColor((lpDrawItem->itemState & ODS_SELECTED) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT));
		DrawText(hdc, lpszPtr, -1, &rRect, DT_SINGLELINE | DT_VCENTER);
	}
}
Example #14
0
void CButtonExtn::DrawButton(HWND hWnd, HDC hDC, RECT *pRect, BOOL fChecked, BOOL fHot, BOOL fFocus)
{
  // Code originally by Nikita Leontiev in answer to "Change checkBox text color Win32"
  // in MS's Forum: "Visual Studio Developer Center > Visual Studio vNext Forums > Visual C++ General"
  // Modified for MFC, Checkbox and Radio buttons by DK

  int nWidth = pRect -> right - pRect -> left;
  int nHeight = pRect -> bottom - pRect -> top;

  HDC hMemDC = CreateCompatibleDC(hDC);
  HBITMAP hBitmap = CreateCompatibleBitmap(hDC, nWidth, nHeight);
  SelectObject(hMemDC, hBitmap);

  RECT rFillRect = {0, 0, nWidth, nHeight};

  HTHEME hTheme = OpenThemeData(hWnd, L"BUTTON");
  int nStateID(0);

  if (m_type == BS_AUTOCHECKBOX) {
    nStateID = (fChecked) ? CBS_CHECKEDNORMAL : CBS_UNCHECKEDNORMAL;
    if (fHot)
      nStateID = (fChecked) ? CBS_CHECKEDHOT : CBS_UNCHECKEDHOT;
  } else {
    nStateID = (fChecked) ? RBS_CHECKEDNORMAL : RBS_UNCHECKEDNORMAL;
    if (fHot)
      nStateID = (fChecked) ? RBS_CHECKEDHOT : RBS_UNCHECKEDHOT;
  }

  //If bg color isn't set, try get backgroung color from current theme
  if (m_bUseBkgColour) {
    FillRect(hMemDC, &rFillRect, CreateSolidBrush(GetSysColor(m_icolour)));
  }
  else { 
    // Don't check IsThemeBackgroundPartiallyTransparent because it return false for BP_CHECKBOX
    DrawThemeParentBackground(hWnd, hMemDC, &rFillRect);
  }

  RECT rIconRect = {0, 0, 13, nHeight};
  DrawThemeBackground(hTheme, hMemDC, m_type == BS_AUTOCHECKBOX ? BP_CHECKBOX : BP_RADIOBUTTON,
                      nStateID, &rIconRect, NULL);
  CloseThemeData(hTheme);

  RECT rTextRect = {16, 0, nWidth - 16, nHeight};
  SetBkMode(hMemDC, TRANSPARENT);
  if (m_bUseTextColour)
    SetTextColor(hMemDC, m_crfText);

  SelectObject(hMemDC, (HFONT)GetStockObject(DEFAULT_GUI_FONT));

  if (m_caption.IsEmpty()) {
    GetWindowText(m_caption);
    SetWindowText(L"");
  }

  DrawText(hMemDC, m_caption, m_caption.GetLength(), &rTextRect, DT_SINGLELINE | DT_VCENTER);

  if (fFocus){
    DrawText(hMemDC, m_caption, m_caption.GetLength(), &rTextRect, DT_SINGLELINE | DT_VCENTER | DT_CALCRECT);
    rTextRect.left--;
    rTextRect.right++;
    DrawFocusRect(hMemDC, &rTextRect);
  }

  BitBlt(hDC, 0, 0, nWidth, nHeight, hMemDC, 0, 0, SRCCOPY);

  DeleteObject(hBitmap);
  DeleteDC(hMemDC);
}
/*  This function is called by the Windows function DispatchMessage()  */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
    static HWND hwndButton1, hwndButton2, hwndButton3, hwndButton4, hwndButton5, hwndButton6, hwndButton7;
    static HWND hwndCheckBox3, hwndCheckBox5, hwndCheckBox6;
    static HBITMAP hBitmap;
    static int cxClient, cyClient, cxSource, cySource;
    BITMAP bitmap;
    HDC hdc, hdcMem;
    int x, y;
    PAINTSTRUCT ps;
    LPDRAWITEMSTRUCT pdis;
    POINT pt[3];
    RECT rc,rect, rectTemp;
    HPEN hPen;
    HBRUSH hBrush;
    HBRUSH hbr;

    UINT coll = 0;
    COLORREF colRef;

    HDC hDC = GetDC(hwnd);
	static BOOL IsDrawing = FALSE;
	static int StartX, StartY;
	static int EndX, EndY;

	static BOOL isLine, isFreeHand, isEllipse, isTriangle, isRectangle, isEraser;
    int state;

    switch (message) {                                                           /* handle the messages */

        case WM_CREATE:
            hBitmap = LoadBitmap (hInst, TEXT ("header"));
            GetObject (hBitmap, sizeof (BITMAP), &bitmap);
            cxSource = bitmap.bmWidth;
            cySource = bitmap.bmHeight;

            hwndButton1 = CreateWindow ( TEXT("BUTTON"), TEXT (""),
                                        WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
                                        50, 60, 30, 30,
                                        hwnd, (HMENU) IDB_BUTTON1, hInst, NULL);
            hwndButton2 = CreateWindow ( TEXT("BUTTON"), TEXT (""),
                                        WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
                                        50, 95, 30, 30,
                                        hwnd, (HMENU) IDB_BUTTON2, hInst, NULL);
            hwndCheckBox3 = CreateWindow ( TEXT("BUTTON"), TEXT (""),
                                          WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
                                          20, 130, 13, 13,
                                          hwnd, (HMENU) IDR_RADIOBUTTON3, hInst, NULL);
            hwndButton3 = CreateWindow ( TEXT("BUTTON"), TEXT (""),
                                        WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
                                        50, 130, 30, 30,
                                        hwnd, (HMENU) IDB_BUTTON3, hInst, NULL);
            hwndButton4 = CreateWindow ( TEXT("BUTTON"), TEXT (""),
                                        WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
                                        50, 165, 30, 30,
                                        hwnd, (HMENU) IDB_BUTTON4, hInst, NULL);
            hwndCheckBox5 = CreateWindow ( TEXT("BUTTON"), TEXT (""),
                                          WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
                                          20, 200, 13, 13,
                                          hwnd, (HMENU) IDR_RADIOBUTTON5, hInst, NULL);
            hwndButton5 = CreateWindow ( TEXT("BUTTON"), TEXT (""),
                                        WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
                                        50, 200, 30, 30,
                                        hwnd, (HMENU) IDB_BUTTON5, hInst, NULL);
            hwndCheckBox6 = CreateWindow ( TEXT("BUTTON"), TEXT (""),
                                          WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
                                          20, 235, 13, 13,
                                          hwnd, (HMENU) IDR_RADIOBUTTON6, hInst, NULL);
            hwndButton6 = CreateWindow ( TEXT("BUTTON"), TEXT (""),
                                        WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
                                        50, 235, 30, 30,
                                        hwnd, (HMENU) IDB_BUTTON6, hInst, NULL);
            hwndButton7 = CreateWindow ( TEXT("BUTTON"), TEXT (""),
                                        WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
                                        50, 270, 30, 30,
                                        hwnd, (HMENU) IDB_BUTTON7, hInst, NULL);
            return 0 ;
        case WM_DRAWITEM :
            pdis = (LPDRAWITEMSTRUCT) lParam;
            FillRect (pdis->hDC, &pdis->rcItem, (HBRUSH) GetStockObject (WHITE_BRUSH));
            FrameRect (pdis->hDC, &pdis->rcItem, (HBRUSH) GetStockObject (BLACK_BRUSH));
            switch (pdis->CtlID) {
                case IDB_BUTTON1 :

                    hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
                    SelectObject(pdis->hDC, hPen);
                    MoveToEx (pdis->hDC, 5, 18, NULL) ;
                    LineTo (pdis->hDC, 19, 4) ;

                    hPen = CreatePen(PS_SOLID, 2, RGB(0, 0, 0));
                    SelectObject(pdis->hDC, hPen);
                    MoveToEx (pdis->hDC, 8, 21, NULL) ;
                    LineTo (pdis->hDC, 22, 7) ;

                    hPen = CreatePen(PS_SOLID, 3, RGB(0, 0, 0));
                    SelectObject(pdis->hDC, hPen);
                    MoveToEx (pdis->hDC, 11, 25, NULL);
                    LineTo (pdis->hDC, 25, 11);
                    break;
                case IDB_BUTTON2 :
                    pt[0].x = 3; pt[0].y = 3;
                    pt[1].x = 3; pt[1].y = 27;
                    pt[2].x = 27; pt[2].y = 15;
                    pt[3].x = 27; pt[3].y = 3;
                    DrawBezier (pdis->hDC, pt);
                    break;
                case IDB_BUTTON3 :
                    state = SendMessage(hwndCheckBox3, BM_GETCHECK, 0, 0);
                    if(state == BST_CHECKED) {
                        Circle (pdis->hDC, 3, 3, 24, true);
                    } else {
                        Circle (pdis->hDC, 3, 3, 24, false);
                    }
                    break;
                case IDB_BUTTON4 :

                    hPen = CreatePen(PS_SOLID, 3, RGB(0, 0, 0));
                    SelectObject(pdis->hDC, hPen);
                    MoveToEx (pdis->hDC, 8, 21, NULL) ;
                    LineTo (pdis->hDC, 22, 7) ;

                    hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
                    SelectObject(pdis->hDC, hPen);
                    MoveToEx (pdis->hDC, 8, 21, NULL);
                    LineTo (pdis->hDC, 3, 24);
                    break;
                case IDB_BUTTON5 :

                    pt[0].x = 4;  pt[0].y = 26;
                    pt[1].x = 26; pt[1].y = 26;
                    pt[2].x = 15; pt[2].y = 3;
                    Triangle (pdis->hDC, pt);
                    break;
                case IDB_BUTTON6 :

                    pt[0].x = 3; pt[0].y = 3;
                    pt[1].x = 3; pt[1].y = 26;
                    pt[2].x = 26; pt[2].y = 26;
                    pt[3].x = 26; pt[3].y = 3;
                    Rectangle(pdis->hDC, pt);
                    break;
                case IDB_BUTTON7 :

                    pt[0].x = 3; pt[0].y = 20;
                    pt[1].x = 6; pt[1].y = 15;
                    pt[2].x = 16; pt[2].y = 15;
                    pt[3].x = 13; pt[3].y = 20;
                    Rectangle(pdis->hDC, pt);

                    hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
                    SelectObject(pdis->hDC, hPen);
                    MoveToEx (pdis->hDC, 6, 15, NULL);
                    LineTo (pdis->hDC, 15, 11);
                    MoveToEx (pdis->hDC, 16, 15, NULL);
                    LineTo (pdis->hDC, 25, 11);
                    MoveToEx (pdis->hDC, 13, 20, NULL);
                    LineTo (pdis->hDC, 22, 16);
                    MoveToEx (pdis->hDC, 15, 11, NULL);
                    LineTo (pdis->hDC, 25, 11);
                    MoveToEx (pdis->hDC, 25, 11, NULL);
                    LineTo (pdis->hDC, 21, 17);
                    break;
            }

            if (pdis->itemState & ODS_SELECTED)
                InvertRect (pdis->hDC, &pdis->rcItem);
            if (pdis->itemState & ODS_FOCUS)                            // Draw a focus rectangle if the button has the focus
                DrawFocusRect (pdis->hDC, &pdis->rcItem) ;
            return 0;
        case WM_LBUTTONDOWN:

                if((LOWORD(lParam) > 15) && (HIWORD(lParam) > 400) &&
                   (LOWORD(lParam) < 90) && (HIWORD(lParam) <550) ) {
                    coll = 255* (HIWORD(lParam) - 400)/150;
                    updateColorPreview(hDC, RGB(coll, coll, coll), 15, 350);
                    colRef = RGB(coll, coll, coll);
                    return 0;
                }
                hDC = GetDC(hwnd);
                StartX = LOWORD(lParam);
                StartY = HIWORD(lParam);
                EndX = LOWORD(lParam);
                EndY = HIWORD(lParam);
                if(isLine) {
                    hPen = CreatePen(PS_SOLID, 1, colRef);
                    hbr = CreateSolidBrush(colRef);
                    SelectObject(hDC, hPen);
                    SelectObject(hDC, hbr);
                    SetROP2(hDC, R2_XORPEN);
                    MoveToEx(hDC, StartX, StartY, NULL);
                    LineTo(hDC, EndX, EndY);
                    IsDrawing = TRUE;
					DeleteObject(hPen);
                    DeleteObject(hbr);
                }
                if(isFreeHand) {
                    hPen = CreatePen(PS_SOLID, 1, colRef);
                    hbr = CreateSolidBrush(colRef);
                    SelectObject(hDC, hPen);
                    SelectObject(hDC, hbr);
                    StartX = LOWORD(lParam);
                    StartY = HIWORD(lParam);
                    IsDrawing = TRUE;
					DeleteObject(hPen);
                    DeleteObject(hbr);
                }
                if(isEllipse){
                    state = SendMessage(hwndCheckBox3, BM_GETCHECK, 0, 0);
                    hPen = CreatePen(PS_SOLID, 1, colRef);
                    if(state){
                        hbr = CreateSolidBrush(colRef);
                        SelectObject(hDC, hbr);
                    } else {
                        hbr = (HBRUSH)GetStockObject(NULL_BRUSH);
                        SelectObject(hDC, hbr);
                    }
                    SelectObject(hDC, hPen);
                    SetROP2(hDC, R2_XORPEN);
                    Ellipse(hDC, StartX, StartY, EndX, EndY);
                    ReleaseDC(hwnd, hDC);
                    IsDrawing = TRUE;
            		DeleteObject(hPen);
                    DeleteObject(hbr);
                }
                if (isTriangle) {
                    state = SendMessage(hwndCheckBox5, BM_GETCHECK, 0, 0);
                    hPen = CreatePen(PS_SOLID, 1, colRef);
                    if (state){
                        hbr = CreateSolidBrush(colRef);
                        SelectObject(hDC, hbr);
                    } else {
                        hbr = (HBRUSH)GetStockObject(NULL_BRUSH);
                        SelectObject(hDC, hbr);
                    }
                    SelectObject(hDC, hPen);
                    SetROP2(hDC, R2_XORPEN);

                    pt[0].x = StartX;  pt[0].y = EndY;
                    pt[1].x = (EndX + StartX) / 2; pt[1].y = StartY;
                    pt[2].x = EndX; pt[2].y = EndY;
                    Triangle(hDC, pt);
                    ReleaseDC(hwnd, hDC);
                    IsDrawing = TRUE;
            		DeleteObject(hPen);
                    DeleteObject(hbr);
                }
                if (isRectangle) {
                    hPen = CreatePen(PS_SOLID, 1, colRef);
                    state = SendMessage(hwndCheckBox6, BM_GETCHECK, 0, 0);
                    if (state) {
                        hbr = CreateSolidBrush(colRef);
                    } else {
                        hbr = (HBRUSH)GetStockObject(NULL_BRUSH);
                    }
                    SelectObject(hDC, hbr);
                    SelectObject(hDC, hPen);
                    SetROP2(hDC, R2_XORPEN);

                    pt[0].x = StartX; pt[0].y = StartY;
                    pt[1].x = StartX; pt[1].y = EndY;
                    pt[2].x = EndX; pt[2].y = EndY;
                    pt[3].x = EndX; pt[3].y = StartY;
                    Rectangle(hDC, pt);
                    ReleaseDC(hwnd, hDC);
                    IsDrawing = TRUE;
            		DeleteObject(hPen);
                    DeleteObject(hbr);
                }
                if (isEraser) {
                    rect.left = StartX - 15;
                    rect.right = StartX + 15;
                    rect.top = StartY - 15;
                    rect.bottom = StartY + 15 ;
                    InvalidateRect(hwnd, &rect, FALSE);
                    SendMessage(hwnd, WM_PAINT, 0, 0);
                    ValidateRect(hwnd, &rect);
                }
                ReleaseDC(hwnd, hDC);
                return 0;

        case WM_MOUSEMOVE:

            if(IsDrawing) {
                hDC = GetDC(hwnd);

                if(isLine) {
                    hPen = CreatePen(PS_SOLID, 1, colRef);
                    SelectObject(hDC, hPen);
                    SetROP2(hDC, R2_NOTXORPEN);
                    MoveToEx(hDC, StartX, StartY, NULL);
                    LineTo(hDC, EndX, EndY);
                    EndX = LOWORD(lParam);
                    EndY = HIWORD(lParam);
                    MoveToEx(hDC, StartX, StartY, NULL);
                    LineTo(hDC, EndX, EndY);
					DeleteObject(hPen);
                }
                if(isFreeHand)  {
                    hPen = CreatePen(PS_SOLID, 1, colRef);
                    SelectObject(hDC, hPen);
                    MoveToEx(hDC, EndX, EndY, NULL);
				    EndX = LOWORD(lParam);
				    EndY = HIWORD(lParam);
				    LineTo(hDC, EndX, EndY);
					DeleteObject(hPen);
                }
                if(isEllipse) {
                    hPen = CreatePen(PS_SOLID, 1, colRef);
                    state = SendMessage(hwndCheckBox3, BM_GETCHECK, 0, 0);
                    if(state) {
                        hbr = CreateSolidBrush(colRef);
                    } else {
                        hbr = (HBRUSH)GetStockObject(NULL_BRUSH);
                    }
                    SelectObject(hDC, hbr);
                    SelectObject(hDC, hPen);
                    SetROP2(hDC, R2_NOTXORPEN);
                    Ellipse(hDC, StartX, StartY, EndX, EndY);
                    EndX = LOWORD(lParam);
                    EndY = HIWORD(lParam);
                    Ellipse(hDC, StartX, StartY, EndX, EndY);
                    DeleteObject(hbr);
                    DeleteObject(hPen);
                }
                if(isTriangle) {
                    hPen = CreatePen(PS_SOLID, 1, colRef);
                    state = SendMessage(hwndCheckBox5, BM_GETCHECK, 0, 0);
                    if (state){
                        hbr = CreateSolidBrush(colRef);
                    } else {
                        hbr = (HBRUSH)GetStockObject(NULL_BRUSH);
                    }
                    SelectObject(hDC, hbr);
                    SelectObject(hDC, hPen);
                    SetROP2(hDC, R2_NOTXORPEN);
                    pt[0].x = StartX;  pt[0].y = EndY;
                    pt[1].x = (EndX + StartX) / 2; pt[1].y = StartY;
                    pt[2].x = EndX; pt[2].y = EndY;
                    Triangle(hDC, pt);
                    EndX = LOWORD(lParam);
                    EndY = HIWORD(lParam);
                    pt[0].x = StartX;  pt[0].y = EndY;
                    pt[1].x = (EndX + StartX) / 2; pt[1].y = StartY;
                    pt[2].x = EndX ; pt[2].y = EndY;
                    Triangle(hDC, pt);
                    DeleteObject(hPen);
                    DeleteObject(hbr);
                }
                if (isRectangle) {
                    hPen = CreatePen(PS_SOLID, 1, colRef);
                    state = SendMessage(hwndCheckBox6, BM_GETCHECK, 0, 0);
                    hPen = CreatePen(PS_SOLID, 1, colRef);
                    if(state) {
                        hbr = CreateSolidBrush(colRef);
                        SelectObject(hDC, hbr);
                    } else {
                        hbr = (HBRUSH)GetStockObject(NULL_BRUSH);
                        SelectObject(hDC, hbr);
                    }
                    SelectObject(hDC, hPen);
                    SetROP2(hDC, R2_NOTXORPEN);
                    pt[0].x = StartX ;  pt[0].y = StartY;
                    pt[1].x = StartX; pt[1].y = EndY ;
                    pt[2].x = EndX ; pt[2].y = EndY ;
                    pt[3].x = EndX ; pt[3].y = StartY ;
                    Rectangle(hDC, pt);
                    EndX = LOWORD(lParam);
                    EndY = HIWORD(lParam);
                    pt[0].x = StartX;  pt[0].y = StartY;
                    pt[1].x = StartX; pt[1].y = EndY;
                    pt[2].x = EndX; pt[2].y = EndY;
                    pt[3].x = EndX; pt[3].y = StartY;
                    Rectangle(hDC, pt);
                    DeleteObject(hPen);
                    DeleteObject(hbr);
                }
                if (isEraser) {
                    SetROP2(hDC, R2_NOTXORPEN);
                    rect.left = StartX - 5;
                    rect.right = StartX + 5;
                    rect.top = StartY - 5;
                    rect.bottom = StartY + 5 ;
                    InvalidateRect(hwnd, &rect, FALSE);
                    SendMessage(hwnd, WM_PAINT, 0, 0);
                    ValidateRect(hwnd, &rect);
                    EndX = LOWORD(lParam);
                    EndY = HIWORD(lParam);
                    rect.left = EndX - 5;
                    rect.right = EndX + 5;
                    rect.top = EndY - 5;
                    rect.bottom = EndY + 5 ;
                    InvalidateRect(hwnd, &rect, FALSE);
                    SendMessage(hwnd, WM_PAINT, 0, 0);
                    ValidateRect(hwnd, &rect);

                }
            }
            ReleaseDC(hwnd, hDC);
            break;
        case WM_LBUTTONUP:

            hDC = GetDC(hwnd);
            EndX = LOWORD(lParam);
            EndY = HIWORD(lParam);
            SetROP2(hDC, R2_XORPEN);
            MoveToEx(hDC, StartX, StartY, NULL);
            LineTo(hDC, EndX, EndY);
            IsDrawing = FALSE;
            ReleaseDC(hwnd, hDC);
            break;
        case WM_SIZE:
            cxClient = LOWORD (lParam);
            cyClient = HIWORD (lParam);
            return 0;
        case WM_COMMAND :
            switch (LOWORD(wParam)){
                case IDB_BUTTON1:
                    isEraser = false;
                    isRectangle = false;
                    isLine = true;
                    isFreeHand = false;
                    isEllipse = false;
                    isTriangle = false;
                    break;
                case IDB_BUTTON3:
                    isEraser = false;
                    isRectangle = false;
                    isLine = false;
                    isFreeHand = false;
                    isEllipse = true;
                    isTriangle = false;
                    break;
                case IDB_BUTTON4:
                    isEraser = false;
                    isRectangle = false;
                    isLine = false;
                    isFreeHand = true;
                    isEllipse = false;
                    isTriangle = false;
                    break;
                case IDB_BUTTON5:
                    isEraser = false;
                    isRectangle = false;
                    isTriangle = true;
                    isLine = false;
                    isFreeHand = false;
                    isEllipse = false;
                    break;
                case IDB_BUTTON6:
                    isEraser = false;
                    isRectangle = true;
                    isTriangle = false;
                    isLine = false;
                    isFreeHand = false;
                    isEllipse = false;
                    break;
                case IDB_BUTTON7:
                    isEraser = true;
                    isRectangle = false;
                    isTriangle = false;
                    isLine = false;
                    isFreeHand = false;
                    isEllipse = false;
                    break;
            }
            GetWindowRect (hwnd, &rc);
            return 0;
        case WM_PAINT:
            /*draw the header*/
            hdc = BeginPaint (hwnd, &ps);
            hdcMem = CreateCompatibleDC (hdc);
            SelectObject (hdcMem, hBitmap);
            for (y = 0 ; y < cySource ; y += cySource)
                for (x = 0 ; x < cxSource ; x += cxSource)
                    BitBlt (hdc, x, y, cxSource, cySource, hdcMem, 0, 0, SRCCOPY);
            DeleteDC (hdcMem) ;
            updateColorPreview(hdc, colRef, 15, 350);
            rectTemp.top = 400;
            rectTemp.bottom = 550;
            rectTemp.left =15;
            rectTemp.right =90;

            for(int l = 0; l < 150; l++) {
                int r;
                r = l * 255 / 150;
                rectTemp.top = 400 + l;
                rectTemp.bottom = 400 + l + 1;
                hBrush = CreateSolidBrush(RGB(r, r, r));
                FillRect(hdc, &rectTemp, hBrush);
                DeleteObject(hBrush);
            }

            EndPaint (hwnd, &ps) ;
            return 0;
        case WM_DESTROY:
            DeleteObject (hBitmap) ;
            PostQuitMessage (0);                                                /* send a WM_QUIT to the message queue */
            break;
        default:                                                                /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }
    return 0;
}
Example #16
0
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam,LPARAM lParam)

{

	static HWND                   hwndSmaller, hwndLarger ;

	static int                           cxClient, cyClient, cxChar, cyChar ;

	int                                                  cx, cy ;

	LPDRAWITEMSTRUCT pdis ;

	POINT                                                pt[3] ;

	RECT                                                       rc ;



	switch (message)

	{

	case   WM_CREATE :

		cxChar = LOWORD (GetDialogBaseUnits ()) ;

		cyChar = HIWORD (GetDialogBaseUnits ()) ;



		// Create the owner-draw pushbuttons



		hwndSmaller = CreateWindow (TEXT ("button"), TEXT (""),

			WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,

			0, 0, BTN_WIDTH, BTN_HEIGHT,

			hwnd, (HMENU) ID_SMALLER, hInst, NULL) ;



		hwndLarger  = CreateWindow (TEXT ("button"), TEXT (""),

			WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,

			0, 0, BTN_WIDTH, BTN_HEIGHT,

			hwnd, (HMENU) ID_LARGER, hInst, NULL) ;

		return 0 ;



	case   WM_SIZE :

		cxClient = LOWORD (lParam) ;

		cyClient = HIWORD (lParam) ;

		// Move the buttons to the new center



		MoveWindow    (      hwndSmaller, cxClient / 2 - 3 *    BTN_WIDTH  / 2,

			cyClient / 2 -    BTN_HEIGHT / 2,

			BTN_WIDTH, BTN_HEIGHT, TRUE) ;

		MoveWindow (  hwndLarger,   cxClient / 2 + BTN_WIDTH  / 2,cyClient / 2 -  BTN_HEIGHT / 2,

			BTN_WIDTH, BTN_HEIGHT, TRUE) ;

		return 0 ;



	case   WM_COMMAND :

		GetWindowRect (hwnd, &rc) ;



		// Make the window 10% smaller or larger



		switch (wParam)

		{

		case   ID_SMALLER :

			rc.left       += cxClient / 20 ;

			rc.right      -= cxClient / 20 ;

			rc.top        += cyClient / 20 ;

			rc.bottom     -= cyClient / 20 ;

			break ;



		case   ID_LARGER :

			rc.left       -= cxClient / 20 ;

			rc.right      += cxClient / 20 ;

			rc.top        -= cyClient / 20 ;

			rc.bottom     += cyClient / 20 ;

			break ;

		}



		MoveWindow (  hwnd, rc.left, rc.top, rc.right  - rc.left,

			rc.bottom - rc.top, TRUE) ;

		return 0 ;



	case   WM_DRAWITEM :

		pdis = (LPDRAWITEMSTRUCT) lParam ;

		// Fill area with white and frame it black
		FillRect(pdis->hDC, &pdis->rcItem, (HBRUSH) GetStockObject (WHITE_BRUSH)) ;

		FrameRect (   pdis->hDC, &pdis->rcItem, (HBRUSH) GetStockObject (BLACK_BRUSH)) ;

		// Draw inward and outward black triangles
		cx = pdis->rcItem.right  - pdis->rcItem.left ;
		cy = pdis->rcItem.bottom - pdis->rcItem.top  ;


		switch (pdis->CtlID)
		{

		case   ID_SMALLER :

			pt[0].x = 3 * cx / 8 ;  pt[0].y = 1 * cy / 8 ;

			pt[1].x = 5 * cx / 8 ;  pt[1].y = 1 * cy / 8 ;

			pt[2].x = 4 * cx / 8 ;  pt[2].y = 3 * cy / 8 ;

			Triangle (pdis->hDC, pt) ;

			pt[0].x = 7 * cx / 8 ;  pt[0].y = 3 * cy / 8 ;

			pt[1].x = 7 * cx / 8 ;  pt[1].y = 5 * cy / 8 ;

			pt[2].x = 5 * cx / 8 ;  pt[2].y = 4 * cy / 8 ;

			Triangle (pdis->hDC, pt) ;

			pt[0].x = 5 * cx / 8 ;  pt[0].y = 7 * cy / 8 ;

			pt[1].x = 3 * cx / 8 ;  pt[1].y = 7 * cy / 8 ;

			pt[2].x = 4 * cx / 8 ;  pt[2].y = 5 * cy / 8 ;

			Triangle (pdis->hDC, pt) ;

			pt[0].x = 1 * cx / 8 ;  pt[0].y = 5 * cy / 8 ;

			pt[1].x = 1 * cx / 8 ;  pt[1].y = 3 * cy / 8 ;

			pt[2].x = 3 * cx / 8 ;  pt[2].y = 4 * cy / 8 ;

			Triangle (pdis->hDC, pt) ;

			break ;



		case ID_LARGER :

			pt[0].x = 5 * cx / 8 ;  pt[0].y = 3 * cy / 8 ;

			pt[1].x = 3 * cx / 8 ;  pt[1].y = 3 * cy / 8 ;

			pt[2].x = 4 * cx / 8 ;  pt[2].y = 1 * cy / 8 ;



			Triangle (pdis->hDC, pt) ;



			pt[0].x = 5 * cx / 8 ;  pt[0].y = 5 * cy / 8 ;

			pt[1].x = 5 * cx / 8 ;  pt[1].y = 3 * cy / 8 ;

			pt[2].x = 7 * cx / 8 ;  pt[2].y = 4 * cy / 8 ;



			Triangle (pdis->hDC, pt) ;

			pt[0].x = 3 * cx / 8 ;  pt[0].y = 5 * cy / 8 ;

			pt[1].x = 5 * cx / 8 ;  pt[1].y = 5 * cy / 8 ;

			pt[2].x = 4 * cx / 8 ;  pt[2].y = 7 * cy / 8 ;



			Triangle (pdis->hDC, pt) ;

			pt[0].x = 3 * cx / 8 ;  pt[0].y = 3 * cy / 8 ;

			pt[1].x = 3 * cx / 8 ;  pt[1].y = 5 * cy / 8 ;

			pt[2].x = 1 * cx / 8 ;  pt[2].y = 4 * cy / 8 ;



			Triangle (pdis->hDC, pt) ;

			break ;

		}



		// Invert the rectangle if the button is selected



		if (pdis->itemState & ODS_SELECTED)

			InvertRect (pdis->hDC, &pdis->rcItem) ;



		// Draw a focus rectangle if the button has the focus



		if (pdis->itemState & ODS_FOCUS)
		{

			pdis->rcItem.left  += cx / 16 ;

			pdis->rcItem.top   += cy / 16 ;

			pdis->rcItem.right -= cx / 16 ;

			pdis->rcItem.bottom-= cy / 16 ;

			DrawFocusRect (pdis->hDC, &pdis->rcItem) ;

		}

		return 0 ;



	case   WM_DESTROY :

		PostQuitMessage (0) ;

		return 0 ;

	}

	return DefWindowProc (hwnd, message, wParam, lParam) ;

}
Example #17
0
static void on_draw_item(HWND hDlg, WPARAM wParam, LPARAM lParam)
{
    static HBRUSH black_brush = 0;
    LPDRAWITEMSTRUCT draw_info = (LPDRAWITEMSTRUCT)lParam;

    if (!black_brush) black_brush = CreateSolidBrush(0);

    if (draw_info->CtlID == IDC_SYSPARAM_COLOR)
    {
        UINT state;
        HTHEME theme;
        RECT buttonrect;

        theme = OpenThemeData(NULL, WC_BUTTONW);

        if (theme) {
            MARGINS margins;

            if (draw_info->itemState & ODS_DISABLED)
                state = PBS_DISABLED;
            else if (draw_info->itemState & ODS_SELECTED)
                state = PBS_PRESSED;
            else
                state = PBS_NORMAL;

            if (IsThemeBackgroundPartiallyTransparent(theme, BP_PUSHBUTTON, state))
                DrawThemeParentBackground(draw_info->hwndItem, draw_info->hDC, NULL);

            DrawThemeBackground(theme, draw_info->hDC, BP_PUSHBUTTON, state, &draw_info->rcItem, NULL);

            buttonrect = draw_info->rcItem;

            GetThemeMargins(theme, draw_info->hDC, BP_PUSHBUTTON, state, TMT_CONTENTMARGINS, &draw_info->rcItem, &margins);

            buttonrect.left += margins.cxLeftWidth;
            buttonrect.top += margins.cyTopHeight;
            buttonrect.right -= margins.cxRightWidth;
            buttonrect.bottom -= margins.cyBottomHeight;

            if (draw_info->itemState & ODS_FOCUS)
                DrawFocusRect(draw_info->hDC, &buttonrect);

            CloseThemeData(theme);
        } else {
            state = DFCS_ADJUSTRECT | DFCS_BUTTONPUSH;

            if (draw_info->itemState & ODS_DISABLED)
                state |= DFCS_INACTIVE;
            else
                state |= draw_info->itemState & ODS_SELECTED ? DFCS_PUSHED : 0;

            DrawFrameControl(draw_info->hDC, &draw_info->rcItem, DFC_BUTTON, state);

            buttonrect = draw_info->rcItem;
        }

        if (!(draw_info->itemState & ODS_DISABLED))
        {
            HBRUSH brush;
            int index = SendDlgItemMessageW(hDlg, IDC_SYSPARAM_COMBO, CB_GETCURSEL, 0, 0);

            index = SendDlgItemMessageW(hDlg, IDC_SYSPARAM_COMBO, CB_GETITEMDATA, index, 0);
            brush = CreateSolidBrush(metrics[index].color);

            InflateRect(&buttonrect, -1, -1);
            FrameRect(draw_info->hDC, &buttonrect, black_brush);
            InflateRect(&buttonrect, -1, -1);
            FillRect(draw_info->hDC, &buttonrect, brush);
            DeleteObject(brush);
        }
    }
}
Example #18
0
static int CALLBACK CheckboxWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
	CCheckboxData *dat = (CCheckboxData*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
	if (!dat)
		return 0;

	switch (Msg) {
	case UM_INITCHECKBOX:
		{
			HFONT hFont = (HFONT)SendMessage(hWnd, WM_GETFONT, 0, 0);
			if (!hFont)
				hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);

			LOGFONT lf;
			GetObject(hFont, sizeof(lf), &lf);
			lf.lfWeight = FW_BOLD;
			dat->hFont = CreateFontIndirect(&lf);
			SendMessage(hWnd, UM_AUTOSIZE, 0, 0);
		}
		return 0;

	case UM_AUTOSIZE:
		{
			HTHEME hTheme = OpenThemeData(hWnd, L"BUTTON");
			int Len = GetWindowTextLength(hWnd) + 1;
			HDC hdc = GetDC(hWnd);
			HFONT hOldFont = (HFONT)SelectObject(hdc, dat->hFont);
			RECT rcText = { 0 };
			if (hTheme) {
				WCHAR *szText = (WCHAR*)_alloca(Len * sizeof(WCHAR));
				GetWindowTextW(hWnd, szText, Len);
				GetThemeTextExtent(hTheme, hdc, BP_GROUPBOX, IsWindowEnabled(hWnd) ? GBS_NORMAL : GBS_DISABLED, szText, -1, DT_CALCRECT | DT_LEFT | DT_VCENTER | DT_SINGLELINE, nullptr, &rcText);
			}
			else {
				SIZE size;
				wchar_t *szText = (wchar_t*)_alloca(Len * sizeof(wchar_t));
				GetWindowText(hWnd, szText, Len);
				GetTextExtentPoint32(hdc, szText, (int)mir_wstrlen(szText), &size);
				rcText.right = size.cx;
				rcText.bottom = size.cy;
			}

			SelectObject(hdc, hOldFont);
			ReleaseDC(hWnd, hdc);
			if (hTheme)
				CloseThemeData(hTheme);

			OffsetRect(&rcText, CG_CHECKBOX_INDENT + CG_CHECKBOX_WIDTH + CG_TEXT_INDENT, 0);
			RECT rc;
			GetClientRect(hWnd, &rc);
			SetWindowPos(hWnd, nullptr, 0, 0, rcText.right + CG_ADDITIONAL_WIDTH, rc.bottom, SWP_NOMOVE | SWP_NOZORDER);
		}
		break;

	case BM_CLICK:
		SendMessage(hWnd, WM_LBUTTONDOWN, 0, 0);
		SendMessage(hWnd, WM_LBUTTONUP, 0, 0);
		return 0;

	case BM_GETCHECK:
		return dat->State & CGSM_ISCHECKED;

	case BM_SETCHECK:
		if ((wParam != BST_UNCHECKED && wParam != BST_CHECKED && wParam != BST_INDETERMINATE) || (wParam == BST_INDETERMINATE && dat->Style != BS_3STATE && dat->Style != BS_AUTO3STATE))
			wParam = BST_CHECKED;
		dat->State &= ~CGSM_ISCHECKED;
		dat->State |= wParam;
		InvalidateRect(hWnd, nullptr, false);
		SendMessage(GetParent(hWnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hWnd), BN_CLICKED), (LPARAM)hWnd);
		return 0;

	case BM_SETSTATE:
		if (wParam)
			dat->State |= CGS_PRESSED;
		else
			dat->State &= ~CGS_PRESSED;
		InvalidateRect(hWnd, nullptr, false);
		return 0;

	case BM_GETSTATE:
		return (dat->State & CGSM_GETSTATE) | ((GetFocus() == hWnd) ? BST_FOCUS : 0);

	case WM_GETDLGCODE:
		return DLGC_BUTTON;

	case WM_THEMECHANGED:
	case WM_ENABLE:
		InvalidateRect(hWnd, nullptr, false);
		return 0;

	case WM_SETTEXT:
		if (CallWindowProc(dat->OldWndProc, hWnd, Msg, wParam, lParam))
			SendMessage(hWnd, UM_AUTOSIZE, 0, 0);
		return 0;

	case WM_KEYDOWN:
		if (wParam == VK_SPACE)
			SendMessage(hWnd, BM_SETSTATE, true, 0);
		return 0;

	case WM_KEYUP:
		if (wParam == VK_SPACE) {
			SendMessage(hWnd, BM_SETCHECK, (SendMessage(hWnd, BM_GETCHECK, 0, 0) + 1) % ((dat->Style == BS_AUTO3STATE) ? 3 : 2), 0);
			SendMessage(hWnd, BM_SETSTATE, false, 0);
		}
		return 0;

	case WM_CAPTURECHANGED:
		SendMessage(hWnd, BM_SETSTATE, false, 0);
		return 0;

	case WM_ERASEBKGND:
		return true;

	case WM_LBUTTONDOWN:
	case WM_LBUTTONDBLCLK:
		SetFocus(hWnd);
		SendMessage(hWnd, BM_SETSTATE, true, 0);
		SetCapture(hWnd);
		return 0;

	case WM_LBUTTONUP:
		if (GetCapture() == hWnd)
			ReleaseCapture();

		SendMessage(hWnd, BM_SETSTATE, false, 0);
		if (dat->State & CGS_HOVERED && (dat->Style == BS_AUTOCHECKBOX || dat->Style == BS_AUTO3STATE))
			SendMessage(hWnd, BM_SETCHECK, (SendMessage(hWnd, BM_GETCHECK, 0, 0) + 1) % ((dat->Style == BS_AUTO3STATE) ? 3 : 2), 0);
		return 0;

	case WM_MOUSEMOVE:
		{
			TRACKMOUSEEVENT tme = { 0 };
			tme.cbSize = sizeof(tme);
			tme.dwFlags = TME_LEAVE;
			tme.dwHoverTime = HOVER_DEFAULT;
			tme.hwndTrack = hWnd;
			_TrackMouseEvent(&tme);
		}

		POINT pt;
		GetCursorPos(&pt);
		if ((WindowFromPoint(pt) == hWnd) ^ ((dat->State & CGS_HOVERED) != 0)) {
			dat->State ^= CGS_HOVERED;
			InvalidateRect(hWnd, nullptr, false);
		}
		return 0;

	case WM_MOUSELEAVE:
		if (dat->State & CGS_HOVERED) {
			dat->State &= ~CGS_HOVERED;
			InvalidateRect(hWnd, nullptr, false);
		}
		return 0;

	case WM_SETFOCUS:
	case WM_KILLFOCUS:
	case WM_SYSCOLORCHANGE:
		InvalidateRect(hWnd, nullptr, false);
		return 0;

	case WM_PAINT:
		{
			HDC hdc;
			PAINTSTRUCT ps;
			hdc = BeginPaint(hWnd, &ps);
			RECT rc;
			GetClientRect(hWnd, &rc);
			HDC hdcMem = CreateCompatibleDC(hdc);
			HBITMAP hbmMem = CreateCompatibleBitmap(hdc, rc.right, rc.bottom);
			HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, hbmMem);
			HTHEME hTheme = OpenThemeData(hWnd, L"BUTTON");
			if (hTheme)
				DrawThemeParentBackground(hWnd, hdcMem, nullptr);
			else
				FillRect(hdcMem, &rc, GetSysColorBrush(COLOR_3DFACE));

			int StateID = 0;
			switch (SendMessage(hWnd, BM_GETCHECK, 0, 0)) {
			case BST_CHECKED:
				StateID += CBSCHECK_CHECKED;
				break;
			case BST_UNCHECKED:
				StateID += CBSCHECK_UNCHECKED;
				break;
			case BST_INDETERMINATE:
				StateID += CBSCHECK_MIXED;
				break;
			}
			if (!IsWindowEnabled(hWnd))
				StateID += CBSSTATE_DISABLED;
			else if (dat->State & CGS_PRESSED && (GetCapture() != hWnd || dat->State & CGS_HOVERED))
				StateID += CBSSTATE_PRESSED;
			else if (dat->State & CGS_PRESSED || dat->State & CGS_HOVERED)
				StateID += CBSSTATE_HOT;

			rc.left += CG_CHECKBOX_INDENT;
			rc.right = rc.left + CG_CHECKBOX_WIDTH; // left-align the image in the client area
			rc.top += CG_CHECKBOX_VERTINDENT;
			rc.bottom = rc.top + CG_CHECKBOX_WIDTH; // exact rc dimensions are necessary for DrawFrameControl to draw correctly
			if (hTheme)
				DrawThemeBackground(hTheme, hdcMem, BP_CHECKBOX, StateID, &rc, &rc);
			else {
				int dfcStates[] =
				{ 0, 0, DFCS_PUSHED, DFCS_INACTIVE,
				DFCS_CHECKED, DFCS_CHECKED, DFCS_CHECKED | DFCS_PUSHED, DFCS_CHECKED | DFCS_INACTIVE,
				DFCS_BUTTON3STATE | DFCS_CHECKED, DFCS_BUTTON3STATE | DFCS_CHECKED, DFCS_BUTTON3STATE | DFCS_INACTIVE | DFCS_CHECKED | DFCS_PUSHED, DFCS_BUTTON3STATE | DFCS_INACTIVE | DFCS_CHECKED | DFCS_PUSHED };
				_ASSERT(StateID >= 1 && StateID <= _countof(dfcStates));
				DrawFrameControl(hdcMem, &rc, DFC_BUTTON, dfcStates[StateID - 1]);
			}

			GetClientRect(hWnd, &rc);
			rc.left += CG_CHECKBOX_INDENT + CG_CHECKBOX_WIDTH + CG_TEXT_INDENT;

			int Len = GetWindowTextLength(hWnd) + 1;
			wchar_t *szTextT = (wchar_t*)_alloca(Len * sizeof(wchar_t));
			GetWindowText(hWnd, szTextT, Len);

			HFONT hOldFont = (HFONT)SelectObject(hdcMem, dat->hFont);
			SetBkMode(hdcMem, TRANSPARENT);
			if (hTheme)
				DrawThemeText(hTheme, hdcMem, BP_GROUPBOX, IsWindowEnabled(hWnd) ? GBS_NORMAL : GBS_DISABLED, szTextT, -1, DT_LEFT | DT_VCENTER | DT_SINGLELINE, 0, &rc);
			else
				DrawText(hdcMem, szTextT, -1, &rc, DT_LEFT | DT_VCENTER | DT_SINGLELINE);

			if (GetFocus() == hWnd) {
				RECT rcText = { 0 };
				if (hTheme)
					GetThemeTextExtent(hTheme, hdcMem, BP_GROUPBOX, IsWindowEnabled(hWnd) ? GBS_NORMAL : GBS_DISABLED, szTextT, -1, DT_CALCRECT | DT_LEFT | DT_VCENTER | DT_SINGLELINE, nullptr, &rcText);
				else {
					SIZE size;
					GetTextExtentPoint32(hdcMem, szTextT, (int)mir_wstrlen(szTextT), &size);
					rcText.right = size.cx;
					rcText.bottom = size.cy;
				}
				rcText.bottom = rc.bottom;
				OffsetRect(&rcText, rc.left, 0);
				InflateRect(&rcText, 1, -1);
				DrawFocusRect(hdcMem, &rcText);
			}
			SelectObject(hdcMem, hOldFont);
			if (hTheme)
				CloseThemeData(hTheme);

			BitBlt(hdc, 0, 0, rc.right, rc.bottom, hdcMem, 0, 0, SRCCOPY);
			SelectObject(hdcMem, hbmOld);
			DeleteObject(hbmMem);
			DeleteDC(hdcMem);
			EndPaint(hWnd, &ps);
		}
		return 0;

	case WM_DESTROY:
		if (dat->hFont)
			DeleteObject(dat->hFont);

		SetWindowLongPtr(hWnd, GWLP_USERDATA, 0);
		CallWindowProc(dat->OldWndProc, hWnd, Msg, wParam, lParam);
		delete dat;
		return 0;
	}
	return CallWindowProc(dat->OldWndProc, hWnd, Msg, wParam, lParam);
}
Example #19
0
void ProjectTreeItem::DrawFocusedItem(HDC dc)
{
	RECT r = {left - 4, top - 3, right + 4, bottom + 3};
	DrawFocusRect(dc, &r);
}
Example #20
0
void CUploadListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
    if (!theApp.emuledlg->IsRunning())
        return;
    if (!lpDrawItemStruct->itemData)
        return;

    // ==> Visual Studio 2010 Compatibility [Stulle/Avi-3k/ied] - Stulle
    /*
    CMemDC dc(CDC::FromHandle(lpDrawItemStruct->hDC), &lpDrawItemStruct->rcItem);
    */
    CMemoryDC dc(CDC::FromHandle(lpDrawItemStruct->hDC), &lpDrawItemStruct->rcItem);
    // <== Visual Studio 2010 Compatibility [Stulle/Avi-3k/ied] - Stulle
    BOOL bCtrlFocused;
    //Xman narrow font at transferwindow
    /*
    InitItemMemDC(dc, lpDrawItemStruct, bCtrlFocused);
    */
    // ==> Design Settings [eWombat/Stulle] - Stulle
    /*
    InitItemMemDC(dc, lpDrawItemStruct, bCtrlFocused, true);
    //Xman end
    */
    InitItemMemDC(dc, lpDrawItemStruct, bCtrlFocused, true, style_b_uploadlist);
    // <== Design Settings [eWombat/Stulle] - Stulle
    CRect cur_rec(lpDrawItemStruct->rcItem);
    CRect rcClient;
    GetClientRect(&rcClient);
    const CUpDownClient *client = (CUpDownClient *)lpDrawItemStruct->itemData;

    // ==> Design Settings [eWombat/Stulle] - Stulle
    /*
    COLORREF crOldBackColor = dc->GetBkColor(); //Xman PowerRelease
    */
    // <== Design Settings [eWombat/Stulle] - Stulle
    //Xman Xtreme Upload
    /*
    if (client->GetSlotNumber() > theApp.uploadqueue->GetActiveUploadsCount())
        dc.SetTextColor(::GetSysColor(COLOR_GRAYTEXT));
    }
    */
    const ThrottledFileSocket* socket=(client->GetFileUploadSocket());
    if( socket!=NULL)
    {
        // ==> Design Settings [eWombat/Stulle] - Stulle
        /*
        if (socket->IsFull())
        	dc.SetTextColor(RGB(0,0,0));
        else if (socket->IsTrickle())
        	dc.SetTextColor(::GetSysColor(COLOR_GRAYTEXT));
        */
#define MLC_BLEND(A, B, X) ((A + B * (X-1) + ((X+1)/2)) / X)

#define MLC_RGBBLEND(A, B, X) (                   \
	RGB(MLC_BLEND(GetRValue(A), GetRValue(B), X), \
	MLC_BLEND(GetGValue(A), GetGValue(B), X),     \
	MLC_BLEND(GetBValue(A), GetBValue(B), X))     \
)
        if (socket->IsFull())
            ;
        else if (socket->IsTrickle())
            dc.SetTextColor(MLC_RGBBLEND(dc.GetTextColor(), dc.GetBkColor(), 2));
        // <== Design Settings [eWombat/Stulle] - Stulle
        //Xman this is used for testing purpose
        else
        {
            if(socket->isready)
                dc.SetTextColor(RGB(0,0,255));
            else
                dc.SetTextColor(RGB(0,128,128));

        }
    }
    //Xman this is used for testing purpose
    else
        dc.SetTextColor(RGB(255,0,0));
    //Xman end

    CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl();
    int iCount = pHeaderCtrl->GetItemCount();
    cur_rec.right = cur_rec.left - sm_iLabelOffset;
    cur_rec.left += sm_iIconOffset;
    for (int iCurrent = 0; iCurrent < iCount; iCurrent++)
    {
        int iColumn = pHeaderCtrl->OrderToIndex(iCurrent);
        if (!IsColumnHidden(iColumn))
        {
            UINT uDrawTextAlignment;
            int iColumnWidth = GetColumnWidth(iColumn, uDrawTextAlignment);
            cur_rec.right += iColumnWidth;
            if (cur_rec.left < cur_rec.right && HaveIntersection(rcClient, cur_rec))
            {
                TCHAR szItem[1024];
                GetItemDisplayText(client, iColumn, szItem, _countof(szItem));
                switch (iColumn)
                {
                case 0: {
                    int iImage;
                    //Xman Show correct Icons
                    /*
                    if (client->IsFriend())
                    	iImage = 4;
                    else if (client->GetClientSoft() == SO_EDONKEYHYBRID) {
                    	if (client->credits->GetScoreRatio(client->GetIP()) > 1)
                    		iImage = 8;
                    	else
                    		iImage = 7;
                    }
                    else if (client->GetClientSoft() == SO_MLDONKEY) {
                    	if (client->credits->GetScoreRatio(client->GetIP()) > 1)
                    		iImage = 6;
                    	else
                    		iImage = 5;
                    }
                    else if (client->GetClientSoft() == SO_SHAREAZA) {
                    	if (client->credits->GetScoreRatio(client->GetIP()) > 1)
                    		iImage = 10;
                    	else
                    		iImage = 9;
                    }
                    else if (client->GetClientSoft() == SO_AMULE) {
                    	if (client->credits->GetScoreRatio(client->GetIP()) > 1)
                    		iImage = 12;
                    	else
                    		iImage = 11;
                    }
                    else if (client->GetClientSoft() == SO_LPHANT) {
                    	if (client->credits->GetScoreRatio(client->GetIP()) > 1)
                    		iImage = 14;
                    	else
                    		iImage = 13;
                    }
                    else if (client->ExtProtocolAvailable()) {
                    	if (client->credits->GetScoreRatio(client->GetIP()) > 1)
                    		iImage = 3;
                    	else
                    		iImage = 1;
                    }
                    else {
                    	if (client->credits->GetScoreRatio(client->GetIP()) > 1)
                    		iImage = 2;
                    	else
                    		iImage = 0;
                    }
                    */
                    if (client->IsFriend())
                        iImage = 6;
                    else if (client->GetClientSoft() == SO_EDONKEYHYBRID) {
                        iImage = 10;
                    }
                    else if (client->GetClientSoft() == SO_EDONKEY) {
                        iImage = 2;
                    }
                    else if (client->GetClientSoft() == SO_MLDONKEY) {
                        iImage = 8;
                    }
                    else if (client->GetClientSoft() == SO_SHAREAZA) {
                        iImage = 12;
                    }
                    else if (client->GetClientSoft() == SO_AMULE) {
                        iImage = 14;
                    }
                    else if (client->GetClientSoft() == SO_LPHANT) {
                        iImage = 16;
                    }
                    else if (client->ExtProtocolAvailable()) {
                        // ==> Mod Icons - Stulle
                        /*
                        iImage = 4;
                        */
                        if(client->GetModClient() == MOD_NONE)
                            iImage = 4;
                        else
                            iImage = (uint8)(client->GetModClient() + 19);
                        // <== Mod Icons - Stulle
                    }
                    else {
                        iImage = 0;
                    }
                    //Xman Anti-Leecher
                    if(client->IsLeecher()>0)
                        iImage=18;
                    else
                        //Xman end
                        // ==> Mod Icons - Stulle
                        // ==> CreditSystems [EastShare/ MorphXT] - Stulle
                        /*
                        if (((client->credits)?client->credits->GetScoreRatio(client):0) > 1)
                        	iImage++;
                        */
                        if (client->GetModClient() == MOD_NONE) {
                            if(client->credits && client->credits->GetHasScore(client))
                                iImage++;
                        }
                    // <== CreditSystems [EastShare/ MorphXT] - Stulle
                    // <== Mod Icons - Stulle
                    //Xman end

                    UINT nOverlayImage = 0;
                    if ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED))
                        nOverlayImage |= 1;
                    //Xman changed: display the obfuscation icon for all clients which enabled it
                    /*
                    if (client->IsObfuscatedConnectionEstablished())
                    */
                    if(client->IsObfuscatedConnectionEstablished()
                            || (!(client->socket != NULL && client->socket->IsConnected())
                                && (client->SupportsCryptLayer() && thePrefs.IsClientCryptLayerSupported() && (client->RequestsCryptLayer() || thePrefs.IsClientCryptLayerRequested()))))
                        //Xman end
                        nOverlayImage |= 2;
                    int iIconPosY = (cur_rec.Height() > 16) ? ((cur_rec.Height() - 16) / 2) : 1;
                    POINT point = { cur_rec.left, cur_rec.top + iIconPosY };

                    //Xman friend visualization
                    if (client->IsFriend() && client->GetFriendSlot())
                        m_ImageList.Draw(dc,19, point, ILD_NORMAL);
                    //Xman end

                    //EastShare Start - added by AndCycle, IP to Country
                    if(theApp.ip2country->ShowCountryFlag() )
                    {
                        cur_rec.left+=20;
                        POINT point2= {cur_rec.left,cur_rec.top+1};
                        //theApp.ip2country->GetFlagImageList()->Draw(dc, client->GetCountryFlagIndex(), point2, ILD_NORMAL);
                        theApp.ip2country->GetFlagImageList()->DrawIndirect(&theApp.ip2country->GetFlagImageDrawParams(dc,client->GetCountryFlagIndex(),point2));
                        cur_rec.left += sm_iLabelOffset;
                    }
                    //EastShare End - added by AndCycle, IP to Country

                    m_ImageList.Draw(dc, iImage, point, ILD_NORMAL | INDEXTOOVERLAYMASK(nOverlayImage));

                    // ==> Mod Icons - Stulle
                    if(client->Credits() && client->credits->GetHasScore(client) && client->GetModClient() != MOD_NONE)
                    {
                        if(nOverlayImage & 1)
                            m_overlayimages.Draw(dc,1, point, ILD_TRANSPARENT);
                        else
                            m_overlayimages.Draw(dc,0, point, ILD_TRANSPARENT);
                    }
                    // <== Mod Icons - Stulle

                    cur_rec.left += 16 + sm_iLabelOffset;
                    dc.DrawText(szItem, -1, &cur_rec, MLC_DT_TEXT | uDrawTextAlignment);
                    cur_rec.left -= 16;
                    cur_rec.right -= sm_iSubItemInset;

                    //EastShare Start - added by AndCycle, IP to Country
                    if(theApp.ip2country->ShowCountryFlag() )
                    {
                        cur_rec.left-=20;
                    }
                    //EastShare End - added by AndCycle, IP to Country

                    break;
                }

                case 7:
                {
                    cur_rec.bottom--;
                    cur_rec.top++;
                    COLORREF crOldBackColor = dc->GetBkColor(); //Xman Code Improvement: FillSolidRect
                    client->DrawUpStatusBar(dc, &cur_rec, false, thePrefs.UseFlatBar());
                    dc.SetBkColor(crOldBackColor); //Xman Code Improvement: FillSolidRect
                    //Xman client percentage (font idea by morph)
                    CString buffer;
                    // ==> Show Client Percentage optional [Stulle] - Stulle
                    /*
                    if (thePrefs.GetUseDwlPercentage())
                    */
                    if (thePrefs.GetShowClientPercentage())
                        // <== Show Client Percentage optional [Stulle] - Stulle
                    {
                        if(client->GetHisCompletedPartsPercent_UP() >=0)
                        {
                            COLORREF oldclr = dc.SetTextColor(RGB(0,0,0));
                            int iOMode = dc.SetBkMode(TRANSPARENT);
                            buffer.Format(_T("%i%%"), client->GetHisCompletedPartsPercent_UP());
                            CFont *pOldFont = dc.SelectObject(&m_fontBoldSmaller);
#define	DrawClientPercentText	dc.DrawText(buffer, buffer.GetLength(),&cur_rec, ((MLC_DT_TEXT | DT_RIGHT) & ~DT_LEFT) | DT_CENTER)
                            cur_rec.top-=1;
                            cur_rec.bottom-=1;
                            DrawClientPercentText;
                            cur_rec.left+=1;
                            cur_rec.right+=1;
                            DrawClientPercentText;
                            cur_rec.left+=1;
                            cur_rec.right+=1;
                            DrawClientPercentText;
                            cur_rec.top+=1;
                            cur_rec.bottom+=1;
                            DrawClientPercentText;
                            cur_rec.top+=1;
                            cur_rec.bottom+=1;
                            DrawClientPercentText;
                            cur_rec.left-=1;
                            cur_rec.right-=1;
                            DrawClientPercentText;
                            cur_rec.left-=1;
                            cur_rec.right-=1;
                            DrawClientPercentText;
                            cur_rec.top-=1;
                            cur_rec.bottom-=1;
                            DrawClientPercentText;
                            cur_rec.left++;
                            cur_rec.right++;
                            dc.SetTextColor(RGB(255,255,255));
                            DrawClientPercentText;
                            dc.SelectObject(pOldFont);
                            dc.SetBkMode(iOMode);
                            dc.SetTextColor(oldclr);
                        }
                    }
                    //Xman end

                    cur_rec.bottom++;
                    cur_rec.top--;
                    break;
                }

                // ==> Uploading Chunk Detail Display [SiRoB/Fafner] - Stulle
                case 10:
                {
                    cur_rec.bottom--;
                    cur_rec.top++;
                    client->DrawUpStatusBarChunk(dc,&cur_rec,false,thePrefs.UseFlatBar());
                    CFont *pOldFont = dc.SelectObject(&m_fontBoldSmaller);
                    client->DrawUpStatusBarChunkText(dc,&cur_rec);
                    dc.SelectObject(pOldFont);
                    cur_rec.bottom++;
                    cur_rec.top--;
                }
                break;
                // <== Uploading Chunk Detail Display [SiRoB/Fafner] - Stulle

                default:
                    // ==> Design Settings [eWombat/Stulle] - Stulle
                    /*
                    //Xman PowerRelease //Xman show LowIDs
                    if(iColumn == 1){
                    	const CKnownFile *file = theApp.sharedfiles->GetFileByID(client->GetUploadFileID());
                    	if(file && file->GetUpPriority()==PR_POWER)
                    		dc->SetBkColor(RGB(255,225,225));
                    }
                    else if(iColumn == 8 && client->HasLowID())
                    	dc->SetBkColor(RGB(255,250,200));
                    //Xman End
                    */
                    // <== Design Settings [eWombat/Stulle] - Stulle
                    dc.DrawText(szItem, -1, &cur_rec, MLC_DT_TEXT | uDrawTextAlignment);
                    // ==> Design Settings [eWombat/Stulle] - Stulle
                    /*
                    dc.SetBkColor(crOldBackColor); //Xman PowerRelease //Xman show LowIDs
                    */
                    // <== Design Settings [eWombat/Stulle] - Stulle
                    break;
                }
            }
            cur_rec.left += iColumnWidth;
        }
    }

    DrawFocusRect(dc, lpDrawItemStruct->rcItem, lpDrawItemStruct->itemState & ODS_FOCUS, bCtrlFocused, lpDrawItemStruct->itemState & ODS_SELECTED);
}
Example #21
0
static void RelayoutTocItem(LPNMTVCUSTOMDRAW ntvcd)
{
    // code inspired by http://www.codeguru.com/cpp/controls/treeview/multiview/article.php/c3985/
    LPNMCUSTOMDRAW ncd = &ntvcd->nmcd;
    HWND hTV = ncd->hdr.hwndFrom;
    HTREEITEM hItem = (HTREEITEM)ncd->dwItemSpec;
    RECT rcItem;
    if (0 == ncd->rc.right - ncd->rc.left || 0 == ncd->rc.bottom - ncd->rc.top)
        return;
    if (!TreeView_GetItemRect(hTV, hItem, &rcItem, TRUE))
        return;
    if (rcItem.right > ncd->rc.right)
        rcItem.right = ncd->rc.right;

    // Clear the label
    RECT rcFullWidth = rcItem;
    rcFullWidth.right = ncd->rc.right;
    FillRect(ncd->hdc, &rcFullWidth, GetSysColorBrush(COLOR_WINDOW));

    // Get the label's text
    WCHAR szText[MAX_PATH];
    TVITEM item;
    item.hItem = hItem;
    item.mask = TVIF_TEXT | TVIF_PARAM;
    item.pszText = szText;
    item.cchTextMax = MAX_PATH;
    TreeView_GetItem(hTV, &item);

    // Draw the page number right-aligned (if there is one)
    WindowInfo *win = FindWindowInfoByHwnd(hTV);
    DocTocItem *tocItem = (DocTocItem *)item.lParam;
    ScopedMem<WCHAR> label;
    if (tocItem->pageNo && win && win->IsDocLoaded()) {
        label.Set(win->ctrl->GetPageLabel(tocItem->pageNo));
        label.Set(str::Join(L"  ", label));
    }
    if (label && str::EndsWith(item.pszText, label)) {
        RECT rcPageNo = rcFullWidth;
        InflateRect(&rcPageNo, -2, -1);

        SIZE txtSize;
        GetTextExtentPoint32(ncd->hdc, label, str::Len(label), &txtSize);
        rcPageNo.left = rcPageNo.right - txtSize.cx;

        SetTextColor(ncd->hdc, GetSysColor(COLOR_WINDOWTEXT));
        SetBkColor(ncd->hdc, GetSysColor(COLOR_WINDOW));
        DrawText(ncd->hdc, label, -1, &rcPageNo, DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX);

        // Reduce the size of the label and cut off the page number
        rcItem.right = std::max(rcItem.right - txtSize.cx, 0);
        szText[str::Len(szText) - str::Len(label)] = '\0';
    }

    SetTextColor(ncd->hdc, ntvcd->clrText);
    SetBkColor(ncd->hdc, ntvcd->clrTextBk);

    // Draw the focus rectangle (including proper background color)
    HBRUSH brushBg = CreateSolidBrush(ntvcd->clrTextBk);
    FillRect(ncd->hdc, &rcItem, brushBg);
    DeleteObject(brushBg);
    if ((ncd->uItemState & CDIS_FOCUS))
        DrawFocusRect(ncd->hdc, &rcItem);

    InflateRect(&rcItem, -2, -1);
    DrawText(ncd->hdc, szText, -1, &rcItem, DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_WORD_ELLIPSIS);
}
void CDownloadClientsCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	if (!theApp.emuledlg->IsRunning())
		return;
	if (!lpDrawItemStruct->itemData)
		return;

	CMemDC dc(CDC::FromHandle(lpDrawItemStruct->hDC), &lpDrawItemStruct->rcItem);
	BOOL bCtrlFocused;
	InitItemMemDC(dc, lpDrawItemStruct, bCtrlFocused);
	CRect cur_rec(lpDrawItemStruct->rcItem);
	CRect rcClient;
	GetClientRect(&rcClient);
	const CUpDownClient *client = (CUpDownClient *)lpDrawItemStruct->itemData;

	CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl();
	int iCount = pHeaderCtrl->GetItemCount();
	cur_rec.right = cur_rec.left - sm_iLabelOffset;
	cur_rec.left += sm_iIconOffset;
	for (int iCurrent = 0; iCurrent < iCount; iCurrent++)
	{
		int iColumn = pHeaderCtrl->OrderToIndex(iCurrent);
		if (!IsColumnHidden(iColumn))
		{
			UINT uDrawTextAlignment;
			int iColumnWidth = GetColumnWidth(iColumn, uDrawTextAlignment);
			cur_rec.right += iColumnWidth;
			if (cur_rec.left < cur_rec.right && HaveIntersection(rcClient, cur_rec))
			{
				TCHAR szItem[1024];
				GetItemDisplayText(client, iColumn, szItem, _countof(szItem));
				switch (iColumn)
				{
					case 0:{
						int iImage;
						if (client->credits != NULL)
						{
							if (client->IsFriend())
								iImage = 4;
							else if (client->GetClientSoft() == SO_EDONKEYHYBRID) {
								if (client->credits->GetScoreRatio(client->GetIP()) > 1)
									iImage = 8;
								else
									iImage = 7;
							}
							else if (client->GetClientSoft() == SO_MLDONKEY) {
								if (client->credits->GetScoreRatio(client->GetIP()) > 1)
									iImage = 6;
								else
									iImage = 5;
							}
							else if (client->GetClientSoft() == SO_SHAREAZA) {
								if (client->credits->GetScoreRatio(client->GetIP()) > 1)
									iImage = 10;
								else
									iImage = 9;
							}
							else if (client->GetClientSoft() == SO_AMULE) {
								if (client->credits->GetScoreRatio(client->GetIP()) > 1)
									iImage = 12;
								else
									iImage = 11;
							}
							else if (client->GetClientSoft() == SO_LPHANT) {
								if (client->credits->GetScoreRatio(client->GetIP()) > 1)
									iImage = 14;
								else
									iImage = 13;
							}
							else if (client->ExtProtocolAvailable()) {
								if (client->credits->GetScoreRatio(client->GetIP()) > 1)
									iImage = 3;
								else
									iImage = 1;
							}
							else {
								if (client->credits->GetScoreRatio(client->GetIP()) > 1)
									iImage = 2;
								else
									iImage = 0;
							}
						}
						else
							iImage = 0;

						UINT nOverlayImage = 0;
						if ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED))
							nOverlayImage |= 1;
						if (client->IsObfuscatedConnectionEstablished())
							nOverlayImage |= 2;
						int iIconPosY = (cur_rec.Height() > 16) ? ((cur_rec.Height() - 16) / 2) : 1;
						POINT point = { cur_rec.left, cur_rec.top + iIconPosY };
						m_ImageList.Draw(dc, iImage, point, ILD_NORMAL | INDEXTOOVERLAYMASK(nOverlayImage));

						cur_rec.left += 16 + sm_iLabelOffset;
						dc.DrawText(szItem, -1, &cur_rec, MLC_DT_TEXT | uDrawTextAlignment);
						cur_rec.left -= 16;
						cur_rec.right -= sm_iSubItemInset;
						break;
					}

					case 4:
						cur_rec.bottom--;
						cur_rec.top++;
						client->DrawStatusBar(dc, &cur_rec, false, thePrefs.UseFlatBar());
						cur_rec.bottom++;
						cur_rec.top--;
						break;

					default:
						dc.DrawText(szItem, -1, &cur_rec, MLC_DT_TEXT | uDrawTextAlignment);
						break;
				}
			}
			cur_rec.left += iColumnWidth;
		}
	}

	DrawFocusRect(dc, lpDrawItemStruct->rcItem, lpDrawItemStruct->itemState & ODS_FOCUS, bCtrlFocused, lpDrawItemStruct->itemState & ODS_SELECTED);
}
Example #23
0
/*
 * mark the selected line, if visible, in the style chosen by the
 * client app. This can be TM_SOLID, meaning an inversion of
 * the whole selected area or TM_FOCUS, meaning, inversion of the first
 * cell, and then a dotted focus rectangle for the rest.
 *
 * this function inverts either style, and so will turn the selection
 * both on and off.
 */
void
gtab_invertsel(HWND hwnd, lpTable ptab, HDC hdc_in)
{
	HDC hdc;
	int firstline, lastline;
	long startrow, lastrow, toprow, bottomrow;
	RECT rc;
	int lastcell;



	/* get the selection start and end rows ordered vertically */
	if (ptab->select.nrows == 0) {
	    return;
	} else if (ptab->select.nrows < 0) {
	    startrow = ptab->select.startrow + ptab->select.nrows + 1;
	    lastrow = ptab->select.startrow;
	} else {
	    startrow = ptab->select.startrow;
	    lastrow = ptab->select.startrow + ptab->select.nrows -1;
	}

	/* is selected area (or part of it) visible on screen ?  */
	firstline = gtab_rowtoline(hwnd, ptab, startrow);
	lastline = gtab_rowtoline(hwnd, ptab, lastrow);


	if (firstline < 0) {
	    toprow = gtab_linetorow(hwnd, ptab,
	    		ptab->hdr.fixedselectable ? 0: ptab->hdr.fixedrows);
	    if ((toprow >= startrow)  &&
		(toprow <= lastrow)) {
		    firstline = gtab_rowtoline(hwnd, ptab, toprow);
	    } else {
		return;
	    }
	} else {
	    toprow = 0;
	}


	if (lastline < 0) {
	    bottomrow = gtab_linetorow(hwnd, ptab, ptab->nlines-1);
	    if ((bottomrow <= lastrow) &&
		(bottomrow >=startrow)) {
		    lastline = gtab_rowtoline(hwnd, ptab, bottomrow);
	    } else {
		return;
	    }
	}


	rc.top = ptab->pdata[firstline].linepos.clipstart;
	rc.bottom = ptab->pdata[lastline].linepos.clipend;



	/* selection mode includes a flag TM_FOCUS indicating we should
	 * use a focus rect instead of the traditional inversion for
	 * selections in this table. This interferes with multiple backgrnd
	 * colours less.  However we still do inversion for fixedcols.
	 */

	lastcell = (int)(ptab->select.startcell + ptab->select.ncells - 1);


	/*
	 * invert the whole area for TM_SOLID or just the first
	 * cell for TM_FOCUS
	 */
	rc.left = ptab->pcellpos[ptab->select.startcell].clipstart;
	if (ptab->hdr.selectmode & TM_FOCUS) {
		rc.right = ptab->pcellpos[ptab->select.startcell].clipend;
	}else {
		rc.right = ptab->pcellpos[lastcell].clipend;
	}

	if (hdc_in == NULL) {
		hdc = GetDC(hwnd);
	} else {
		hdc = hdc_in;
	}

	InvertRect(hdc, &rc);

	/*
	 * draw focus rectangle around remaining cells on this line, if there
	 * are any
	 */
	if (ptab->hdr.selectmode & TM_FOCUS) {
		/*
		 * now this is a real fudge. if we are drawing TM_FOCUS
		 * selection, and the real top line is off the top of the
		 * window, then the top of the focus rect will be drawn at
		 * the top of our window. If we then scroll up one line,
		 * a new focus rect will be drawn, but the old top of focus
		 * rect line will still be there as junk on the
		 * screen. To fix this, we have 2 choices: we undo the selection
		 * before every scroll (too slow) or we set the focus rect a little
		 * bigger if the real top line is off-window, so that the top line
		 * is clipped (as it should be). This latter is what we do here
		 */
		if (toprow > startrow) {
		    rc.top--;
		}
		if (ptab->select.ncells > 1) {
			rc.left = ptab->pcellpos[ptab->select.startcell+1].clipstart;
			rc.right = ptab->pcellpos[lastcell].clipend;
			DrawFocusRect(hdc, &rc);
		}
	}

	if (hdc_in == NULL) {
		ReleaseDC(hwnd, hdc);
	}
}
Example #24
0
VOID 
TreeListDrawItem(
	__in PTREELIST_OBJECT Object,
	__in HDC hdc, 
	__in HTREEITEM hTreeItem,
	__in LPARAM lp
	)
{
	RECT rc;
	RECT Rect;
	LONG i;
	UINT Format;
	WCHAR Buffer[MAX_PATH];

	if (!lp) {
		return;
	}

	Rect = Object->ItemRect;

	if(Object->ItemFocus) {
		FillRect(hdc, &Rect, Object->hBrushBack);
		DrawFocusRect(hdc, &Rect);
	}
	else {
		FillRect(hdc, &Rect, Object->hBrushNormal);
	}

	//
	// Always write text as transparent 
	//

	SetBkMode(hdc, TRANSPARENT);

	if (Object->ItemFocus) {
		SetTextColor(hdc, Object->clrHighlight);
	} else {
		SetTextColor(hdc, Object->clrText);
	}

	rc = Rect;

	for(i = 0; i < Object->ColumnCount; i++) {

		if(i != 0) {
			rc.left = Object->Column[i].Rect.left;
		}
		rc.right = Object->Column[i].Rect.right;

		/*
		if (i == 0) { 
			if (rc.right > Object->Column[0].Rect.right) {
				rc.right = Object->Column[0].Rect.right;
				continue;
			}
			if (rc.left > rc.right) {
				rc.left = Object->Column[0].Rect.right;
				continue;
			}
		}
		*/

		TreeListFormatValue(Object, Object->FormatCallback, hTreeItem, (PVOID)lp, i, Buffer, MAX_PATH);
		if (!Object->Column[i].ExpandTab) {
			Format = DT_SINGLELINE|DT_WORD_ELLIPSIS|Object->Column[i].Align;
		} else {
			//Format = DT_SINGLELINE|DT_EXPANDTABS|Object->Column[i].Align;
			Format = DT_SINGLELINE|DT_EXPANDTABS;
		}
		DrawText(hdc, Buffer, -1, &rc, Format);
	}
}
Example #25
0
void FlatButton::DrawItem(LPDRAWITEMSTRUCT dis)
{
	UINT style = DFCS_BUTTONPUSH;

	if (dis->itemState & ODS_DISABLED)
		style |= DFCS_INACTIVE;

	RECT textRect = {dis->rcItem.left+2, dis->rcItem.top+2, dis->rcItem.right-4, dis->rcItem.bottom-4};

	if (dis->itemState & ODS_SELECTED) {
		style |= DFCS_PUSHED;
		++textRect.left;	++textRect.top;
		++textRect.right;	++textRect.bottom;
	}

	FillRect(dis->hDC, &dis->rcItem, GetSysColorBrush(COLOR_BTNFACE));

	 // highlight the button?
	if (_active)
		DrawEdge(dis->hDC, &dis->rcItem, EDGE_ETCHED, BF_RECT);
	else if (GetWindowStyle(_hwnd) & BS_FLAT)	// Only with BS_FLAT there will be drawn a frame to show highlighting.
		DrawEdge(dis->hDC, &dis->rcItem, EDGE_RAISED, BF_RECT|BF_FLAT);

	TCHAR txt[BUFFER_LEN];
	int txt_len = GetWindowText(_hwnd, txt, BUFFER_LEN);

	if (dis->itemState & (ODS_DISABLED|ODS_GRAYED)) {
		COLORREF gray = GetSysColor(COLOR_GRAYTEXT);

		if (gray) {
			{
			TextColor lcColor(dis->hDC, GetSysColor(COLOR_BTNHIGHLIGHT));
			RECT shadowRect = {textRect.left+1, textRect.top+1, textRect.right+1, textRect.bottom+1};
			DrawText(dis->hDC, txt, txt_len, &shadowRect, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
			}

			BkMode mode(dis->hDC, TRANSPARENT);
			TextColor lcColor(dis->hDC, gray);
			DrawText(dis->hDC, txt, txt_len, &textRect, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
		} else {
			int old_r = textRect.right;
			int old_b = textRect.bottom;
			DrawText(dis->hDC, txt, txt_len, &textRect, DT_SINGLELINE|DT_VCENTER|DT_CENTER|DT_CALCRECT);
			int x = textRect.left + (old_r-textRect.right)/2;
			int y = textRect.top + (old_b-textRect.bottom)/2;
			int w = textRect.right-textRect.left;
			int h = textRect.bottom-textRect.top;
			s_MyDrawText_Rect.right = w;
			s_MyDrawText_Rect.bottom = h;
			GrayString(dis->hDC, GetSysColorBrush(COLOR_GRAYTEXT), MyDrawText, (LPARAM)txt, txt_len, x, y, w, h);
		}
	} else {
		TextColor lcColor(dis->hDC, _active? _activeColor: _textColor);
		DrawText(dis->hDC, txt, txt_len, &textRect, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
	}

	if (dis->itemState & ODS_FOCUS) {
		RECT rect = {
			dis->rcItem.left+3, dis->rcItem.top+3,
			dis->rcItem.right-dis->rcItem.left-4, dis->rcItem.bottom-dis->rcItem.top-4
		};
		if (dis->itemState & ODS_SELECTED) {
			++rect.left;	++rect.top;
			++rect.right;	++rect.bottom;
		}
		DrawFocusRect(dis->hDC, &rect);
	}
}
Example #26
0
File: button.c Project: hejin/wine
/**********************************************************************
 *       Push Button Functions
 */
static void PB_Paint( HWND hwnd, HDC hDC, UINT action )
{
    RECT     rc, r;
    UINT     dtFlags, uState;
    HPEN     hOldPen;
    HBRUSH   hOldBrush;
    INT      oldBkMode;
    COLORREF oldTxtColor;
    HFONT hFont;
    LONG state = get_button_state( hwnd );
    LONG style = GetWindowLongW( hwnd, GWL_STYLE );
    BOOL pushedState = (state & BST_PUSHED);
    HWND parent;
    HRGN hrgn;

    GetClientRect( hwnd, &rc );

    /* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */
    if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
    parent = GetParent(hwnd);
    if (!parent) parent = hwnd;
    SendMessageW( parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd );

    hrgn = set_control_clipping( hDC, &rc );

    hOldPen = SelectObject(hDC, SYSCOLOR_GetPen(COLOR_WINDOWFRAME));
    hOldBrush = SelectObject(hDC,GetSysColorBrush(COLOR_BTNFACE));
    oldBkMode = SetBkMode(hDC, TRANSPARENT);

    if (get_button_type(style) == BS_DEFPUSHBUTTON)
    {
        if (action != ODA_FOCUS)
            Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
	InflateRect( &rc, -1, -1 );
    }

    /* completely skip the drawing if only focus has changed */
    if (action == ODA_FOCUS) goto draw_focus;

    uState = DFCS_BUTTONPUSH;

    if (style & BS_FLAT)
        uState |= DFCS_MONO;
    else if (pushedState)
    {
	if (get_button_type(style) == BS_DEFPUSHBUTTON )
	    uState |= DFCS_FLAT;
	else
	    uState |= DFCS_PUSHED;
    }

    if (state & (BST_CHECKED | BST_INDETERMINATE))
        uState |= DFCS_CHECKED;

    DrawFrameControl( hDC, &rc, DFC_BUTTON, uState );

    /* draw button label */
    r = rc;
    dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &r);

    if (dtFlags == (UINT)-1L)
       goto cleanup;

    if (pushedState)
       OffsetRect(&r, 1, 1);

    oldTxtColor = SetTextColor( hDC, GetSysColor(COLOR_BTNTEXT) );

    BUTTON_DrawLabel(hwnd, hDC, dtFlags, &r);

    SetTextColor( hDC, oldTxtColor );

draw_focus:
    if (action == ODA_FOCUS || (state & BST_FOCUS))
    {
        InflateRect( &rc, -2, -2 );
        DrawFocusRect( hDC, &rc );
    }

 cleanup:
    SelectObject( hDC, hOldPen );
    SelectObject( hDC, hOldBrush );
    SetBkMode(hDC, oldBkMode);
    SelectClipRgn( hDC, hrgn );
    if (hrgn) DeleteObject( hrgn );
}
Example #27
0
File: syslink.c Project: bpon/wine
/***********************************************************************
 * SYSLINK_Draw
 * Draws the SysLink control.
 */
static LRESULT SYSLINK_Draw (const SYSLINK_INFO *infoPtr, HDC hdc)
{
    RECT rc;
    PDOC_ITEM Current;
    HFONT hOldFont;
    COLORREF OldTextColor, OldBkColor;
    HBRUSH hBrush;

    hOldFont = SelectObject(hdc, infoPtr->Font);
    OldTextColor = SetTextColor(hdc, infoPtr->TextColor);
    OldBkColor = SetBkColor(hdc, infoPtr->BackColor);
    
    GetClientRect(infoPtr->Self, &rc);
    rc.right -= SL_RIGHTMARGIN + SL_LEFTMARGIN;
    rc.bottom -= SL_BOTTOMMARGIN + SL_TOPMARGIN;

    if(rc.right < 0 || rc.bottom < 0) return 0;

    hBrush = (HBRUSH)SendMessageW(infoPtr->Notify, WM_CTLCOLORSTATIC,
                                  (WPARAM)hdc, (LPARAM)infoPtr->Self);
    if (!hBrush)
        hBrush = CreateSolidBrush(infoPtr->BackColor);
    FillRect(hdc, &rc, hBrush);
    DeleteObject(hBrush);

    for(Current = infoPtr->Items; Current != NULL; Current = Current->Next)
    {
        int n;
        LPWSTR tx;
        PDOC_TEXTBLOCK bl;
        
        bl = Current->Blocks;
        if(bl != NULL)
        {
            tx = Current->Text;
            n = Current->nText;

            if(Current->Type == slText)
            {
                 SelectObject(hdc, infoPtr->Font);
                 SetTextColor(hdc, infoPtr->TextColor);
            }
            else
            {
                 SelectObject(hdc, infoPtr->LinkFont);
                 SetTextColor(hdc, (!(Current->u.Link.state & LIS_VISITED) ? infoPtr->LinkColor : infoPtr->VisitedColor));
            }

            while(n > 0)
            {
                tx += bl->nSkip;
                ExtTextOutW(hdc, bl->rc.left, bl->rc.top, ETO_OPAQUE | ETO_CLIPPED, &bl->rc, tx, bl->nChars, NULL);
                if((Current->Type == slLink) && (Current->u.Link.state & LIS_FOCUSED) && infoPtr->HasFocus)
                {
                    COLORREF PrevTextColor;
                    PrevTextColor = SetTextColor(hdc, infoPtr->TextColor);
                    DrawFocusRect(hdc, &bl->rc);
                    SetTextColor(hdc, PrevTextColor);
                }
                tx += bl->nChars;
                n -= bl->nChars + bl->nSkip;
                bl++;
            }
        }
    }

    SetBkColor(hdc, OldBkColor);
    SetTextColor(hdc, OldTextColor);
    SelectObject(hdc, hOldFont);
    
    return 0;
}
Example #28
0
File: button.c Project: hejin/wine
static void CB_Paint( HWND hwnd, HDC hDC, UINT action )
{
    RECT rbox, rtext, client;
    HBRUSH hBrush;
    int delta;
    UINT dtFlags;
    HFONT hFont;
    LONG state = get_button_state( hwnd );
    LONG style = GetWindowLongW( hwnd, GWL_STYLE );
    HWND parent;
    HRGN hrgn;

    if (style & BS_PUSHLIKE)
    {
        PB_Paint( hwnd, hDC, action );
	return;
    }

    GetClientRect(hwnd, &client);
    rbox = rtext = client;

    if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );

    parent = GetParent(hwnd);
    if (!parent) parent = hwnd;
    hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC,
				  (WPARAM)hDC, (LPARAM)hwnd);
    if (!hBrush) /* did the app forget to call defwindowproc ? */
        hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC,
					(WPARAM)hDC, (LPARAM)hwnd );
    hrgn = set_control_clipping( hDC, &client );

    if (style & BS_LEFTTEXT)
    {
	/* magic +4 is what CTL3D expects */

        rtext.right -= checkBoxWidth + 4;
        rbox.left = rbox.right - checkBoxWidth;
    }
    else
    {
        rtext.left += checkBoxWidth + 4;
        rbox.right = checkBoxWidth;
    }

    /* Since WM_ERASEBKGND does nothing, first prepare background */
    if (action == ODA_SELECT) FillRect( hDC, &rbox, hBrush );
    if (action == ODA_DRAWENTIRE) FillRect( hDC, &client, hBrush );

    /* Draw label */
    client = rtext;
    dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &rtext);
    
    /* Only adjust rbox when rtext is valid */
    if (dtFlags != (UINT)-1L)
    {
	rbox.top = rtext.top;
	rbox.bottom = rtext.bottom;
    }

    /* Draw the check-box bitmap */
    if (action == ODA_DRAWENTIRE || action == ODA_SELECT)
    {
	UINT flags;

	if ((get_button_type(style) == BS_RADIOBUTTON) ||
	    (get_button_type(style) == BS_AUTORADIOBUTTON)) flags = DFCS_BUTTONRADIO;
	else if (state & BST_INDETERMINATE) flags = DFCS_BUTTON3STATE;
	else flags = DFCS_BUTTONCHECK;

	if (state & (BST_CHECKED | BST_INDETERMINATE)) flags |= DFCS_CHECKED;
	if (state & BST_PUSHED) flags |= DFCS_PUSHED;

	if (style & WS_DISABLED) flags |= DFCS_INACTIVE;

	/* rbox must have the correct height */
	delta = rbox.bottom - rbox.top - checkBoxHeight;
	
	if (style & BS_TOP) {
	    if (delta > 0) {
		rbox.bottom = rbox.top + checkBoxHeight;
	    } else { 
		rbox.top -= -delta/2 + 1;
		rbox.bottom = rbox.top + checkBoxHeight;
	    }
	} else if (style & BS_BOTTOM) {
	    if (delta > 0) {
		rbox.top = rbox.bottom - checkBoxHeight;
	    } else {
		rbox.bottom += -delta/2 + 1;
		rbox.top = rbox.bottom - checkBoxHeight;
	    }
	} else { /* Default */
	    if (delta > 0) {
		int ofs = (delta / 2);
		rbox.bottom -= ofs + 1;
		rbox.top = rbox.bottom - checkBoxHeight;
	    } else if (delta < 0) {
		int ofs = (-delta / 2);
		rbox.top -= ofs + 1;
		rbox.bottom = rbox.top + checkBoxHeight;
	    }
	}

	DrawFrameControl( hDC, &rbox, DFC_BUTTON, flags );
    }

    if (dtFlags == (UINT)-1L) /* Noting to draw */
	return;

    if (action == ODA_DRAWENTIRE)
	BUTTON_DrawLabel(hwnd, hDC, dtFlags, &rtext);

    /* ... and focus */
    if (action == ODA_FOCUS || (state & BST_FOCUS))
    {
	rtext.left--;
	rtext.right++;
	IntersectRect(&rtext, &rtext, &client);
	DrawFocusRect( hDC, &rtext );
    }
    SelectClipRgn( hDC, hrgn );
    if (hrgn) DeleteObject( hrgn );
}
Example #29
0
LRESULT dlgWndAskPIN::ProcecEvent
			(	UINT		uMsg,			// Message For This Window
				WPARAM		wParam,			// Additional Message Information
				LPARAM		lParam )		// Additional Message Information
{
	PAINTSTRUCT ps;
	RECT rect;

	switch( uMsg )
	{ 
		case WM_COMMAND:
		{
			switch( LOWORD(wParam) )
			{
				case IDC_EDIT:
				{
					if( EN_CHANGE == HIWORD(wParam) )
					{
						long len = (long)SendMessage( GetDlgItem( m_hWnd, IDC_EDIT ), WM_GETTEXTLENGTH, 0, 0 );
						EnableWindow( GetDlgItem( m_hWnd, IDOK ), ( (unsigned int)len >= m_ulPinMinLen ) );
					}
					return TRUE;
				}

				case IDB_OK:
					GetPinResult();
					dlgResult = eIDMW::DLG_OK;
					close();
					return TRUE;

				case IDB_CANCEL:
					dlgResult = eIDMW::DLG_CANCEL;
					close();
					return TRUE;

				default:
					unsigned short tmp = LOWORD(wParam);
					if( tmp >= IDB_KeypadStart && tmp < IDB_KeypadEnd ) // Keypad Buttons
					{
						wchar_t nameBuf[128];
						SendMessage( GetDlgItem( m_hWnd, IDC_EDIT ), WM_GETTEXT, (WPARAM)(sizeof(nameBuf)), (LPARAM)nameBuf );
						size_t iPos = wcslen( nameBuf );
						if( iPos >= m_ulPinMaxLen )
							return TRUE;
						if( tmp == IDB_KeypadEnd - 1 ) // Keypad Button 0
						{
							nameBuf[ iPos++ ] = L'0';
						}
						else // Keypad Button 1 to 9
						{
							nameBuf[ iPos++ ] = 49 + tmp - IDB_KeypadStart;
						}
						nameBuf[ iPos++ ] = NULL;
						SendMessage( GetDlgItem( m_hWnd, IDC_EDIT ), WM_SETTEXT, 0, (LPARAM)nameBuf );
						return TRUE;
					}
					if( tmp == IDB_KeypadEnd ) // Keypad Button CE
					{
						SendMessage( GetDlgItem( m_hWnd, IDC_EDIT ), WM_SETTEXT, 0, (LPARAM)"" );
						//clear
					}
					return DefWindowProc( m_hWnd, uMsg, wParam, lParam );
			}
		}

		case WM_DRAWITEM:
		{
			LPDRAWITEMSTRUCT lpDrawItem = (LPDRAWITEMSTRUCT)lParam;
			if( lpDrawItem->CtlType & ODT_BUTTON )
			{
				//MWLOG(LEV_DEBUG, MOD_DLG, L" dlgWndAskPIN : Virtual pinpad - WM_DRAWITEM lParam=%x, wParam=%ld",lParam,wParam);
				//MWLOG(LEV_DEBUG, MOD_DLG, L" dlgWndAskPIN : Virtual pinpad - Entering WM_DRAWITEM lpDrawItem->hDC=%ld",lpDrawItem->hDC);

				FillRect( lpDrawItem->hDC, &lpDrawItem->rcItem, CreateSolidBrush( GetSysColor( COLOR_3DFACE ) ) );
				//MWLOG(LEV_DEBUG, MOD_DLG, L" dlgWndAskPIN : Virtual pinpad - WM_DRAWITEM top=%ld, bottom=%ld, left=%ld, right=%ld",
					//lpDrawItem->rcItem.top,lpDrawItem->rcItem.bottom,lpDrawItem->rcItem.left,lpDrawItem->rcItem.right);

				HDC hdcMem = CreateCompatibleDC( lpDrawItem->hDC );
				SelectObject( hdcMem , ImageKP_BTN[11] );
				MaskBlt( lpDrawItem->hDC, (lpDrawItem->rcItem.right - KP_BTN_SIZE) / 2, (lpDrawItem->rcItem.bottom - KP_BTN_SIZE) / 2,
					KP_BTN_SIZE, KP_BTN_SIZE, hdcMem, 0, 0,
					ImageKP_BTN_Mask, 0, 0, MAKEROP4( SRCCOPY, 0x00AA0029 ) );

				unsigned int iNum = 0;
				if( lpDrawItem->CtlID == IDB_KeypadEnd )
				{
					iNum = 10;
				}
				else if( lpDrawItem->CtlID >= IDB_KeypadStart && lpDrawItem->CtlID < IDB_KeypadEnd -2 )
				{
					iNum = lpDrawItem->CtlID - IDB_KeypadStart +1;
				}
				//MWLOG(LEV_DEBUG, MOD_DLG, L" dlgWndAskPIN : Virtual pinpad - WM_DRAWITEM iNum=%ld",iNum);

				SelectObject( hdcMem , ImageKP_BTN[iNum] );
				BitBlt( lpDrawItem->hDC, (lpDrawItem->rcItem.right - KP_LBL_SIZE) / 2, (lpDrawItem->rcItem.bottom - KP_LBL_SIZE) / 2, 
						KP_LBL_SIZE, KP_LBL_SIZE, hdcMem, 0, 0, SRCCOPY );
				DeleteDC(hdcMem);

				if( lpDrawItem->itemState & ODS_SELECTED )
					DrawEdge( lpDrawItem->hDC, &lpDrawItem->rcItem, EDGE_RAISED, BF_RECT );
				
				if( lpDrawItem->itemState & ODS_HOTLIGHT )
					DrawEdge( lpDrawItem->hDC, &lpDrawItem->rcItem, EDGE_SUNKEN, BF_RECT );
				
				if( lpDrawItem->itemState & ODS_FOCUS )
				{
					GetClientRect( lpDrawItem->hwndItem, &rect );
					rect.left += 2;
					rect.right -= 2;
					rect.top += 2;
					rect.bottom -= 2;
					DrawFocusRect( lpDrawItem->hDC, &rect );
				}
				//MWLOG(LEV_DEBUG, MOD_DLG, L" dlgWndAskPIN : Virtual pinpad - Leaving WM_DRAWITEM lpDrawItem->hDC=%ld",lpDrawItem->hDC);
				return TRUE;
			}
			break;
		}

		case WM_SIZE:
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndAskPIN::ProcecEvent WM_SIZE (wParam=%X, lParam=%X)",wParam,lParam);

			if( IsIconic( m_hWnd ) )
				return 0;
			break;
		}

		case WM_PAINT:
		{
			//MWLOG(LEV_DEBUG, MOD_DLG, L" dlgWndAskPIN : WM_PAINT");
			m_hDC = BeginPaint( m_hWnd, &ps );

			HDC hdcMem;

			hdcMem = CreateCompatibleDC( m_hDC );

			HGDIOBJ oldObj = SelectObject( hdcMem , ImagePIN );

			GetClientRect( m_hWnd, &rect );
			MaskBlt( m_hDC, 4, m_KeypadHeight + 8,
				IMG_SIZE, IMG_SIZE,	hdcMem, 0, 0,
				ImagePIN_Mask, 0, 0, MAKEROP4( SRCCOPY, 0x00AA0029 ) );
		
			
			SelectObject( hdcMem, oldObj );
			DeleteDC(hdcMem);

			if( m_UseKeypad )
			{
				GetClientRect( m_hWnd, &rect );
				rect.left += 8;
				rect.right -= 8;
				rect.top += 8;
				rect.bottom = m_KeypadHeight;

				DrawEdge( m_hDC, &rect, EDGE_RAISED, BF_RECT );
			}

			GetClientRect( m_hWnd, &rect );
			rect.left += IMG_SIZE + 16;
			rect.top = m_KeypadHeight + 8;
			rect.right -= 8;
			rect.bottom = rect.bottom - 40;
			SetBkColor( m_hDC, GetSysColor( COLOR_3DFACE ) );
			SelectObject( m_hDC, TextFont );
			DrawText( m_hDC, szHeader, -1, &rect, DT_WORDBREAK );

			EndPaint( m_hWnd, &ps );

			SetForegroundWindow( m_hWnd );

			return 0;
		}

		case WM_ACTIVATE:
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndAskPIN::ProcecEvent WM_ACTIVATE (wParam=%X, lParam=%X)",wParam,lParam);
			break;
		}

		case WM_NCACTIVATE:
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndAskPIN::ProcecEvent WM_NCACTIVATE (wParam=%X, lParam=%X)",wParam,lParam);

			//if( !IsIconic( m_hWnd ) && m_ModalHold && Active_hWnd == m_hWnd )
			//{
			//	ShowWindow( m_hWnd, SW_SHOW );
			//	SetFocus( m_hWnd );
			//	return 0;
			//}
			if(!wParam)
			{
				SetFocus( m_hWnd );
				return 0;
			}
			break;
		}

		case WM_SETFOCUS:
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndAskPIN::ProcecEvent WM_SETFOCUS (wParam=%X, lParam=%X)",wParam,lParam);
			break;
		}

		case WM_KILLFOCUS:
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndAskPIN::ProcecEvent WM_KILLFOCUS (wParam=%X, lParam=%X)",wParam,lParam);

			//if( !IsIconic( m_hWnd ) && m_ModalHold && Active_hWnd == m_hWnd )
			//{
			//	if( GetParent((HWND)wParam ) != m_hWnd )
			//	{
			//		SetFocus( m_hWnd );
			//		return 0;
			//	}
			//}
			break;
		}

		case WM_CREATE:
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndAskPIN::ProcecEvent WM_CREATE (wParam=%X, lParam=%X)",wParam,lParam);

			HMENU hSysMenu;

			hSysMenu = GetSystemMenu( m_hWnd, FALSE );
			EnableMenuItem( hSysMenu, 3, MF_BYPOSITION | MF_GRAYED );
			SendMessage( m_hWnd, DM_SETDEFID, (WPARAM) IDC_EDIT, (LPARAM) 0); 

			return DefWindowProc( (HWND)((CREATESTRUCT *)lParam)->lpCreateParams, uMsg, wParam, lParam );
		}

		case WM_CLOSE:
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndAskPIN::ProcecEvent WM_CLOSE (wParam=%X, lParam=%X)",wParam,lParam);

			if( IsIconic( m_hWnd ) )
				return DefWindowProc( m_hWnd, uMsg, wParam, lParam );

			ShowWindow( m_hWnd, SW_MINIMIZE );
			return 0;
		}

		case WM_DESTROY: 
		{
			MWLOG(LEV_DEBUG, MOD_DLG, L"  --> dlgWndAskPIN::ProcecEvent WM_DESTROY (wParam=%X, lParam=%X)",wParam,lParam);
			break;
		}

		default:
		{
			return DefWindowProc( m_hWnd, uMsg, wParam, lParam );
		}
	}
	return DefWindowProc( m_hWnd, uMsg, wParam, lParam );
}
Example #30
0
DLGBOOL CALLBACK dlgDemoList ( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
    switch ( message )
		{
		case WM_INITDIALOG:
			{
			int tabs[] = {31-7, 81-7};
			SendDlgItemMessage ( hWnd, IDC_LIST_TABS, LB_SETTABSTOPS, 
				sizeof(tabs)/sizeof(tabs[0]), (LPARAM)tabs );
			SendDlgItemMessage ( hWnd, IDC_LIST_TABS, LB_SETHORIZONTALEXTENT, 500, 0 );
			SendDlgItemMessage ( hWnd, IDC_LIST_TABS, LB_ADDSTRING, 0, (LPARAM) "[1]\tThis is tabbed\tYes" );
			SendDlgItemMessage ( hWnd, IDC_LIST_TABS, LB_ADDSTRING, 0, (LPARAM) "This exits from tab space\tOK" );

			SendDlgItemMessage ( hWnd, IDC_LIST_OD, LB_ADDSTRING, 0, (LPARAM)"String 1" );
			SendDlgItemMessage ( hWnd, IDC_LIST_OD, LB_ADDSTRING, 0, (LPARAM)"String 2" );
			SendDlgItemMessage ( hWnd, IDC_LIST_OD, LB_ADDSTRING, 0, (LPARAM)"String 3" );

			SendDlgItemMessage ( hWnd, IDC_LIST_ODV, LB_ADDSTRING, 0, (LPARAM)"String 1" );
			SendDlgItemMessage ( hWnd, IDC_LIST_ODV, LB_ADDSTRING, 0, (LPARAM)"String 2" );
			SendDlgItemMessage ( hWnd, IDC_LIST_ODV, LB_ADDSTRING, 0, (LPARAM)"String 3" );
			SendDlgItemMessage ( hWnd, IDC_LIST_ODV, LB_ADDSTRING, 0, (LPARAM)"String 4" );
			SendDlgItemMessage ( hWnd, IDC_LIST_ODV, LB_ADDSTRING, 0, (LPARAM)"String 5" );
			SendDlgItemMessage ( hWnd, IDC_LIST_ODV, LB_ADDSTRING, 0, (LPARAM)"String 6" );

			SendDlgItemMessage ( hWnd, IDC_LIST_MSEL, LB_ADDSTRING, 0, (LPARAM)"String 1" );
			SendDlgItemMessage ( hWnd, IDC_LIST_MSEL, LB_ADDSTRING, 0, (LPARAM)"String 2" );
			SendDlgItemMessage ( hWnd, IDC_LIST_MSEL, LB_ADDSTRING, 0, (LPARAM)"String 3" );
			SendDlgItemMessage ( hWnd, IDC_LIST_MSEL, LB_ADDSTRING, 0, (LPARAM)"String 4" );
			SendDlgItemMessage ( hWnd, IDC_LIST_MSEL, LB_ADDSTRING, 0, (LPARAM)"String 5" );
			SendDlgItemMessage ( hWnd, IDC_LIST_MSEL, LB_ADDSTRING, 0, (LPARAM)"String 6" );
			SendDlgItemMessage ( hWnd, IDC_LIST_MSEL, LB_ADDSTRING, 0, (LPARAM)"String 7" );
			SendDlgItemMessage ( hWnd, IDC_LIST_MSEL, LB_ADDSTRING, 0, (LPARAM)"String 8" );

			break;
			}

		case WM_DRAWITEM:
			{
			LPDRAWITEMSTRUCT lpDrw = (LPDRAWITEMSTRUCT)lParam;
			if( lpDrw->CtlType != ODT_LISTBOX ) return 0;
			if( lpDrw->itemAction & ODA_DRAWENTIRE )
				{
				char txt[128];
				FillRect ( lpDrw->hDC, &lpDrw->rcItem, GetStockObject(WHITE_BRUSH) );
				SendMessage ( lpDrw->hwndItem, LB_GETTEXT, lpDrw->itemID, (LPARAM)txt );
				TextOut ( lpDrw->hDC, lpDrw->rcItem.left+(lpDrw->rcItem.bottom-lpDrw->rcItem.top)+8,
						  lpDrw->rcItem.top, txt, strlen(txt) );
				if( lpDrw->itemState & ODS_FOCUS )
					{
					lpDrw->rcItem.right--;
					lpDrw->rcItem.left++;
					DrawFocusRect ( lpDrw->hDC, &lpDrw->rcItem );
					}
				}
			if( (lpDrw->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) != 0 )
				{
				SelectObject ( lpDrw->hDC, GetStockObject(BLACK_PEN) );
				if( !(lpDrw->itemState & ODS_SELECTED) )
					SelectObject ( lpDrw->hDC, GetStockObject(DKGRAY_BRUSH) );
				else
					SelectObject ( lpDrw->hDC, GetStockObject(WHITE_BRUSH) );
				Ellipse ( lpDrw->hDC, lpDrw->rcItem.left, lpDrw->rcItem.top, 
						  lpDrw->rcItem.left+(lpDrw->rcItem.bottom-lpDrw->rcItem.top),
						  lpDrw->rcItem.bottom );
				}
			if( (lpDrw->itemAction & ODA_FOCUS) )
				{
				lpDrw->rcItem.right--;
				lpDrw->rcItem.left++;
				DrawFocusRect ( lpDrw->hDC, &lpDrw->rcItem );
				}
			return TRUE;
			}

		case WM_MEASUREITEM:
			{
			LPMEASUREITEMSTRUCT lpMs = (LPMEASUREITEMSTRUCT)lParam;
			//printf ( "WM_MEASUREITEM\n" );
			if( lpMs->CtlID == IDC_LIST_ODV )
				{
				lpMs->itemHeight = 14+3*abs(3-(INT)lpMs->itemID);
				}
			else
				lpMs->itemHeight = 20;
			return TRUE;
			}
		}

	return defDemoDlg ( hWnd, message, wParam, lParam );
}