本文整理汇总了C++中RGB函数的典型用法代码示例。如果您正苦于以下问题:C++ RGB函数的具体用法?C++ RGB怎么用?C++ RGB使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RGB函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetPageOffset
//.........这里部分代码省略.........
}
/////////////////////////////////
// Loop and print column strings
//
int top = r.top;
for(int t = start ; t < end ; t++ )
{
// Tokenize a line of data
CString line( m_data[ t ] );
int quarterHeight = lineHeight / 4;
// Check if this is a separator
if( IsSeparator( line ) )
{
// Draw a line across the grid
dc->SelectStockObject( BLACK_PEN );
dc->MoveTo( r.left, top + quarterHeight );
dc->LineTo( r.right, top + quarterHeight );
}
else if( IsDoubleSeparator( line ) )
{
// Draw a double line across the grid
dc->SelectStockObject( BLACK_PEN );
dc->MoveTo( r.left, top + quarterHeight );
dc->LineTo( r.right, top + quarterHeight );
dc->MoveTo( r.left, top + quarterHeight * 2 );
dc->LineTo( r.right, top + quarterHeight * 2 );
}
else if( IsBoldSeparator( line ) )
{
// Draw a bold line across the grid
boldPen.CreatePen( PS_SOLID, quarterHeight / 2, RGB( 0, 0, 0 ) );
dc->SelectObject( boldPen );
dc->MoveTo( r.left, top + quarterHeight );
dc->LineTo( r.right, top + quarterHeight );
dc->SelectStockObject( BLACK_PEN );
}
else
{
CTokenizer tok( line, _T( "|" ) );
int left = r.left;
// Loop columns
for( int i = 0 ; i < max ; i++ )
{
CColumn* column = m_columns.GetAt( i );
CRect drawRect( left, top, r.right, top + lineHeight );
if( column )
{
// Get the data for this column
CString data;
tok.GetAt( i, data );
// Get the width of the column
int pixelWidth = CUnitConversion::InchesToPixels( column->GetWidth() );
if( pixelWidth == 0 )
pixelWidth = restWidth;
// Set font
CFont* font = fonts.GetAt( i );
CFont* specialFont = NULL;
if( font )
{
示例2: win_proc
//.........这里部分代码省略.........
case BTN_UP: //按钮弹起
if(id==ID_CLOSE)
{
PostMessage(hwnd,MSG_CLOSE,0,0);
}
if(id==ID_LED1)
{
zigbee_LED1_OFF();
}
if(id==ID_LED2)
{
zigbee_LED2_OFF();
}
break;
////
}
}
break;
////
case MSG_PAINT:
{
hdc =BeginPaint(hwnd);
GetClientRect(hwnd,&rc0);
SetFillColor(hdc,RGB(150,150,150));
FillRect(hdc,&rc0);
SetTextColor(hdc,RGB(0,0,128));
SetDrawColor(hdc,RGB(100,100,100));
DrawGroupBox(hdc,&rcZigBeeString,"信息接收区");
////
SetRect(&rc,
rcGroupBox_LED.left,
rcGroupBox_LED.top-(24+2),
RectW(&rcGroupBox_LED),
24);
if(zigbee_is_ok())
{
SetTextColor(hdc,RGB(0,255,0));
SetDrawColor(hdc,RGB(0,200,0));
SetFillColor(hdc,RGB(0,128,0));
DrawText(hdc,"连接成功",-1,&rc,DT_CENTER|DT_VCENTER|DT_BORDER|DT_BKGND);
}
else
{
SetTextColor(hdc,RGB(255,0,0));
SetDrawColor(hdc,RGB(200,0,0));
SetFillColor(hdc,RGB(100,0,0));
if(timer_500ms_count&0x01)
{
DrawText(hdc,"未连接",-1,&rc,DT_CENTER|DT_VCENTER|DT_BORDER|DT_BKGND);
}
else
示例3: ConWndProc
static LONG WINAPI ConWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
char *cmdString;
static qboolean s_timePolarity;
switch (uMsg)
{
case WM_ACTIVATE:
if ( LOWORD( wParam ) != WA_INACTIVE )
{
SetFocus( s_wcd.hwndInputLine );
}
if ( com_viewlog )
{
// if the viewlog is open, check to see if it's being minimized
if ( com_viewlog->integer == 1 )
{
if ( HIWORD( wParam ) ) // minimized flag
{
Cvar_Set( "viewlog", "2" );
}
}
else if ( com_viewlog->integer == 2 )
{
if ( !HIWORD( wParam ) ) // minimized flag
{
Cvar_Set( "viewlog", "1" );
}
}
}
break;
case WM_CLOSE:
//cmdString = CopyString( "quit" );
//Sys_QueEvent( 0, SE_CONSOLE, 0, 0, strlen( cmdString ) + 1, cmdString );
if ( s_wcd.quitOnClose )
{
PostQuitMessage( 0 );
}
else
{
Sys_ShowConsole( 0, qfalse );
Cvar_Set( "viewlog", "0" );
}
return 0;
case WM_CTLCOLORSTATIC:
if ( ( HWND ) lParam == s_wcd.hwndBuffer )
{
SetBkColor( ( HDC ) wParam, RGB( 0, 0, 0 ) );
SetTextColor( ( HDC ) wParam, RGB( 249, 249, 000 ) );
return ( long ) s_wcd.hbrEditBackground;
}
else if ( ( HWND ) lParam == s_wcd.hwndErrorBox )
{
if ( s_timePolarity & 1 )
{
SetBkColor( ( HDC ) wParam, RGB( 0x80, 0x80, 0x80 ) );
SetTextColor( ( HDC ) wParam, RGB( 0xff, 0x00, 0x00 ) );
}
else
{
SetBkColor( ( HDC ) wParam, RGB( 0x80, 0x80, 0x80 ) );
SetTextColor( ( HDC ) wParam, RGB( 0x00, 0x00, 0x00 ) );
}
return ( long ) s_wcd.hbrErrorBackground;
}
return FALSE;
break;
case WM_COMMAND:
if ( wParam == COPY_ID )
{
SendMessage( s_wcd.hwndBuffer, EM_SETSEL, 0, -1 );
SendMessage( s_wcd.hwndBuffer, WM_COPY, 0, 0 );
}
else if ( wParam == QUIT_ID )
{
if ( s_wcd.quitOnClose )
{
PostQuitMessage( 0 );
}
else
{
cmdString = CopyString( "quit" );
Sys_QueEvent( 0, SE_CONSOLE, 0, 0, strlen( cmdString ) + 1, cmdString );
}
}
else if ( wParam == CLEAR_ID )
{
SendMessage( s_wcd.hwndBuffer, EM_SETSEL, 0, -1 );
SendMessage( s_wcd.hwndBuffer, EM_REPLACESEL, FALSE, ( LPARAM ) "" );
UpdateWindow( s_wcd.hwndBuffer );
}
break;
case WM_CREATE:
s_wcd.hbrEditBackground = CreateSolidBrush( RGB( 0x00, 0x00, 0x00 ) );
s_wcd.hbrErrorBackground = CreateSolidBrush( RGB( 0x80, 0x80, 0x80 ) );
SetTimer( hWnd, 1, 1000, NULL );
break;
//.........这里部分代码省略.........
示例4: WndProc
//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
int wmId, wmEvent;
PAINTSTRUCT ps;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_HELP_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDOK:
SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd);
SendMessage (hWnd, WM_CLOSE, 0, 0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_CREATE:
s_sai.cbSize = sizeof(SHACTIVATEINFO);
hwndCB = CreateRpCommandBar(hWnd);
break;
case WM_PAINT:
{
hdc = BeginPaint(hWnd, &ps);
HPEN hpen1, hpen2;
HBRUSH hbr1, hbr2;
hpen1 = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
hpen2 = CreatePen(PS_SOLID, 1, RGB(0, 0, 255));
hbr1 = CreateSolidBrush(RGB(0, 255, 0));
hbr2 = CreateSolidBrush(RGB(0, 255, 255));
SelectObject(hdc, hpen1);
POINT pt[2];
pt[0].x = 10;
pt[0].y = 10;
pt[1].x = 110;
pt[1].y = 10;
Polyline(hdc, pt, 2);
SelectObject(hdc, hbr1);
Rectangle(hdc, 40, 40, 80, 80);
SelectObject(hdc, hpen2);
pt[0].x = 20;
pt[0].y = 20;
pt[1].x = 20;
pt[1].y = 120;
Polyline(hdc, pt, 2);
SelectObject(hdc, hbr2);
Rectangle(hdc, 100, 100, 150, 150);
// Clean Up all objects created.
SelectObject(hdc, GetStockObject(BLACK_PEN));
SelectObject(hdc, GetStockObject(WHITE_BRUSH));
DeleteObject(hpen1);
DeleteObject(hpen2);
DeleteObject(hbr1);
DeleteObject(hbr2);
EndPaint(hWnd, &ps);
}
break;
case WM_DESTROY:
CommandBar_Destroy(hwndCB);
PostQuitMessage(0);
break;
case WM_SETTINGCHANGE:
SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
示例5: IORegView_Paint
void IORegView_Paint(CIORegView* wnd, HWND hWnd, WPARAM wParam, LPARAM lParam)
{
HDC hDC;
PAINTSTRUCT ps;
HDC hMemDC;
HBITMAP hMemBitmap;
RECT rc;
HPEN pen;
int x, y, w, h;
int nameColWidth;
int curx, cury;
SIZE fontsize;
IOReg reg;
char txt[80];
GetClientRect(hWnd, &rc);
x = 0;
y = wnd->rebarHeight;
w = rc.right - wnd->vsbWidth;
h = rc.bottom - wnd->rebarHeight;
curx = kXMargin; cury = wnd->yoff + kYMargin;
hDC = BeginPaint(hWnd, &ps);
hMemDC = CreateCompatibleDC(hDC);
hMemBitmap = CreateCompatibleBitmap(hDC, w, h);
SelectObject(hMemDC, hMemBitmap);
pen = CreatePen(PS_SOLID, 1, RGB(210, 230, 255));
SelectObject(hMemDC, pen);
SelectObject(hMemDC, wnd->hFont);
GetTextExtentPoint32(hMemDC, " ", 1, &fontsize);
FillRect(hMemDC, &rc, (HBRUSH)GetStockObject(WHITE_BRUSH));
reg = IORegs[wnd->CPU][wnd->Reg];
if ((reg.type == AllRegs) || (reg.type == CatBegin))
{
nameColWidth = w - (kXMargin + (fontsize.cx*8) + kXMargin + 1 + kXMargin + kXMargin + 1 + kXMargin + (fontsize.cx*8) + kXMargin);
DrawText(hMemDC, reg.name, curx, cury, w, fontsize.cy, DT_LEFT | DT_END_ELLIPSIS);
cury += fontsize.cy + kYMargin;
MoveToEx(hMemDC, 0, cury, NULL);
LineTo(hMemDC, w, cury);
cury ++;
curx = kXMargin;
DrawText(hMemDC, "Address", curx, cury+kYMargin, fontsize.cx*8, fontsize.cy, DT_LEFT);
curx += (fontsize.cx*8) + kXMargin;
MoveToEx(hMemDC, curx, cury, NULL);
LineTo(hMemDC, curx, h);
curx += 1 + kXMargin;
DrawText(hMemDC, "Name", curx, cury+kYMargin, nameColWidth, fontsize.cy, DT_LEFT | DT_END_ELLIPSIS);
curx += nameColWidth + kXMargin;
MoveToEx(hMemDC, curx, cury, NULL);
LineTo(hMemDC, curx, h);
curx += 1 + kXMargin;
DrawText(hMemDC, "Value", curx, cury+kYMargin, fontsize.cx*8, fontsize.cy, DT_RIGHT);
cury += kYMargin + fontsize.cy + kYMargin;
MoveToEx(hMemDC, 0, cury, NULL);
LineTo(hMemDC, w, cury);
cury += 1 + kYMargin;
for (int i = wnd->Reg+1; ; i++)
{
IOReg curReg = IORegs[wnd->CPU][i];
curx = kXMargin;
if (curReg.type == CatBegin)
{
if (reg.type == AllRegs) continue;
else break;
}
else if (curReg.type == ListEnd)
break;
else if (curReg.type == MMIOReg)
{
u32 val;
sprintf(txt, "%08X", curReg.address);
DrawText(hMemDC, txt, curx, cury, fontsize.cx*8, fontsize.cy, DT_LEFT);
curx += (fontsize.cx*8) + kXMargin + 1 + kXMargin;
DrawText(hMemDC, curReg.name, curx, cury, nameColWidth, fontsize.cy, DT_LEFT | DT_END_ELLIPSIS | DT_NOPREFIX);
curx += nameColWidth + kXMargin + 1 + kXMargin;
switch (curReg.size)
{
case 1:
val = (u32)MMU_read8(wnd->CPU, curReg.address);
sprintf(txt, "%02X", val);
break;
case 2:
val = (u32)MMU_read16(wnd->CPU, curReg.address);
sprintf(txt, "%04X", val);
break;
case 4:
val = MMU_read32(wnd->CPU, curReg.address);
//.........这里部分代码省略.........
示例6: SetPropListFont
void CPropertiesWnd::InitPropList()
{
SetPropListFont();
m_wndPropList.EnableHeaderCtrl(FALSE);
m_wndPropList.EnableDescriptionArea();
m_wndPropList.SetVSDotNetLook();
m_wndPropList.MarkModifiedProperties();
CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("Appearance"));
pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("3D Look"), (_variant_t) false, _T("Specifies the window's font will be non-bold and controls will have a 3D border")));
CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("Border"), _T("Dialog Frame"), _T("One of: None, Thin, Resizable, or Dialog Frame"));
pProp->AddOption(_T("None"));
pProp->AddOption(_T("Thin"));
pProp->AddOption(_T("Resizable"));
pProp->AddOption(_T("Dialog Frame"));
pProp->AllowEdit(FALSE);
pGroup1->AddSubItem(pProp);
pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("Caption"), (_variant_t) _T("About"), _T("Specifies the text that will be displayed in the window's title bar")));
m_wndPropList.AddProperty(pGroup1);
CMFCPropertyGridProperty* pSize = new CMFCPropertyGridProperty(_T("Window Size"), 0, TRUE);
pProp = new CMFCPropertyGridProperty(_T("Height"), (_variant_t) 250l, _T("Specifies the window's height"));
pProp->EnableSpinControl(TRUE, 50, 300);
pSize->AddSubItem(pProp);
pProp = new CMFCPropertyGridProperty( _T("Width"), (_variant_t) 150l, _T("Specifies the window's width"));
pProp->EnableSpinControl(TRUE, 50, 200);
pSize->AddSubItem(pProp);
m_wndPropList.AddProperty(pSize);
CMFCPropertyGridProperty* pGroup2 = new CMFCPropertyGridProperty(_T("Font"));
LOGFONT lf;
CFont* font = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT));
font->GetLogFont(&lf);
lstrcpy(lf.lfFaceName, _T("Arial"));
pGroup2->AddSubItem(new CMFCPropertyGridFontProperty(_T("Font"), lf, CF_EFFECTS | CF_SCREENFONTS, _T("Specifies the default font for the window")));
pGroup2->AddSubItem(new CMFCPropertyGridProperty(_T("Use System Font"), (_variant_t) true, _T("Specifies that the window uses MS Shell Dlg font")));
m_wndPropList.AddProperty(pGroup2);
CMFCPropertyGridProperty* pGroup3 = new CMFCPropertyGridProperty(_T("Misc"));
pProp = new CMFCPropertyGridProperty(_T("(Name)"), _T("Application"));
pProp->Enable(FALSE);
pGroup3->AddSubItem(pProp);
CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("Window Color"), RGB(210, 192, 254), NULL, _T("Specifies the default window color"));
pColorProp->EnableOtherButton(_T("Other..."));
pColorProp->EnableAutomaticButton(_T("Default"), ::GetSysColor(COLOR_3DFACE));
pGroup3->AddSubItem(pColorProp);
static const TCHAR szFilter[] = _T("Icon Files(*.ico)|*.ico|All Files(*.*)|*.*||");
pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("Icon"), TRUE, _T(""), _T("ico"), 0, szFilter, _T("Specifies the window icon")));
pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("Folder"), _T("c:\\")));
m_wndPropList.AddProperty(pGroup3);
CMFCPropertyGridProperty* pGroup4 = new CMFCPropertyGridProperty(_T("Hierarchy"));
CMFCPropertyGridProperty* pGroup41 = new CMFCPropertyGridProperty(_T("First sub-level"));
pGroup4->AddSubItem(pGroup41);
CMFCPropertyGridProperty* pGroup411 = new CMFCPropertyGridProperty(_T("Second sub-level"));
pGroup41->AddSubItem(pGroup411);
pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 1"), (_variant_t) _T("Value 1"), _T("This is a description")));
pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 2"), (_variant_t) _T("Value 2"), _T("This is a description")));
pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 3"), (_variant_t) _T("Value 3"), _T("This is a description")));
pGroup4->Expand(FALSE);
m_wndPropList.AddProperty(pGroup4);
}
示例7: sub_81439D0
void sub_81439D0(void)
{
u8 taskIdA;
s16 taskIdC;
u8 taskIdB;
u16 savedIme;
struct Unk201C000 *c000;
sub_8144130();
SetVBlankCallback(NULL);
ResetPaletteFade();
ResetTasks();
taskIdA = CreateTask(task_a_8143B38, 0);
gTasks[taskIdA].data[TDA_4] = 0;
gTasks[taskIdA].data[TDA_7] = 0;
gTasks[taskIdA].data[TDA_11] = 0;
gTasks[taskIdA].data[TDA_13] = 1;
while (TRUE)
{
if (sub_8144ECC(0, taskIdA))
break;
}
taskIdC = gTasks[taskIdA].data[TDA_TASK_C_ID];
gTasks[taskIdC].data[TDC_0] = 40;
Text_LoadWindowTemplate(&gWindowTemplate_81E7208);
InitMenuWindow(&gWindowTemplate_81E7208);
LoadPalette(&gUnknown_0840B7BC, 0x80, sizeof(gUnknown_0840B7BC));
CpuCopy16(&gUnknown_0840B7FC, (void *)(VRAM + 0xBEE0), sizeof(gUnknown_0840B7FC));
REG_BG0VOFS = 0xFFFC;
taskIdB = CreateTask(task_b_81441B8, 0);
gTasks[taskIdB].data[TDB_TASK_A_ID] = taskIdA;
gTasks[taskIdA].data[TDA_TASK_B_ID] = taskIdB;
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB(0, 0, 0));
savedIme = REG_IME;
REG_IME = 0;
REG_IE |= INTR_FLAG_VBLANK;
REG_IME = savedIme;
REG_DISPSTAT |= DISPSTAT_VBLANK_INTR;
SetVBlankCallback(vblank_8143948);
m4aSongNumStart(BGM_THANKFOR);
SetMainCallback2(sub_814395C);
gUnknown_02039325 = 0;
c000 = &ewram1c000;
sub_81458DC();
c000->unk88 = 0;
c000->unk8A = 0;
c000->unk8C = 0;
gUnknown_02039322 = taskIdA;
}
示例8: PaintBk
void CButtonST::DrawItem(UINT ctrlID, LPDRAWITEMSTRUCT lpDIS)
{
CDCHandle pDC = lpDIS->hDC;
CPenHandle pOldPen;
// Checkbox or Radiobutton style ?
if (m_bIsCheckBox)
{
m_bIsPressed = (lpDIS->itemState & ODS_SELECTED) || m_nCheck;
}
// Normal button OR other button style ...
else
{
m_bIsPressed = (lpDIS->itemState & ODS_SELECTED);
}
m_bIsFocused = (lpDIS->itemState & ODS_FOCUS) != 0;
m_bIsDisabled = (lpDIS->itemState & ODS_DISABLED) != 0;
CRect itemRect = lpDIS->rcItem;
pDC.SetBkMode(TRANSPARENT);
if (!m_bIsFlat)
{
if (m_bIsFocused || GetDefault())
{
CBrush br;
br.CreateSolidBrush(RGB(0,0,0));
pDC.FrameRect(&itemRect, br);
itemRect.DeflateRect(1, 1);
}
}
// Prepare draw... paint button background
// Draw transparent?
if (m_bDrawTransparent)
{
PaintBk(pDC);
}
else
{
OnDrawBackground(pDC, &itemRect);
}
// Draw pressed button
if (m_bIsPressed)
{
if (m_bIsFlat)
{
if (m_bDrawBorder)
{
OnDrawBorder(pDC, &itemRect);
}
}
else
{
CBrush brBtnShadow;
brBtnShadow.CreateSolidBrush(GetSysColor(COLOR_BTNSHADOW));
pDC.FrameRect(&itemRect, brBtnShadow);
}
}
else // ...else draw non pressed button
{
CPen penBtnHiLight; // White
CPen pen3DLight; // Light gray
CPen penBtnShadow; // Dark gray
CPen pen3DDKShadow; // Black
penBtnHiLight.CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_BTNHILIGHT)); // White
pen3DLight.CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_3DLIGHT)); // Light gray
penBtnShadow.CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_BTNSHADOW)); // Dark gray
pen3DDKShadow.CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_3DDKSHADOW)); // Black
if (m_bIsFlat)
{
if (m_bMouseOnButton && m_bDrawBorder)
{
pDC.Draw3dRect(itemRect, ::GetSysColor(COLOR_BTNHILIGHT), ::GetSysColor(COLOR_BTNSHADOW));
}
}
else
{
// Draw top-left borders
// White line
pOldPen = pDC.SelectPen(penBtnHiLight);
pDC.MoveTo(itemRect.left, itemRect.bottom-1);
pDC.LineTo(itemRect.left, itemRect.top);
pDC.LineTo(itemRect.right, itemRect.top);
// Light gray line
pDC.SelectPen(pen3DLight);
pDC.MoveTo(itemRect.left+1, itemRect.bottom-1);
pDC.LineTo(itemRect.left+1, itemRect.top+1);
pDC.LineTo(itemRect.right, itemRect.top+1);
// Draw bottom-right borders
// Black line
pDC.SelectPen(pen3DDKShadow);
pDC.MoveTo(itemRect.left, itemRect.bottom-1);
//.........这里部分代码省略.........
示例9: MsgBoxPop
/**
* Dummi modal MsgBox for popup,
* this set call function in wait stait and do not freece miranda main thread
* the window is outside the desktop
*/
static INT_PTR CALLBACK MsgBoxPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
LPMSGBOX pMsgBox = (LPMSGBOX)lParam;
MoveWindow(hDlg, -10, -10, 0, 0, FALSE);
LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)mir_alloc(sizeof(MSGPOPUPDATA));
if (pmpd) {
POPUPDATAT_V2 pd = { 0 };
pd.cbSize = sizeof(pd);
pd.lchContact = NULL; //(HANDLE)wParam;
// icon
pd.lchIcon = MsgLoadIcon(pMsgBox);
mir_tstrncpy(pd.lptzContactName, pMsgBox->ptszTitle, _countof(pd.lptzContactName));
mir_tstrncpy(pd.lptzText, pMsgBox->ptszMsg, _countof(pd.lptzText));
// CALLBAC Proc
pd.PluginWindowProc = PopupProc;
pd.PluginData = pmpd;
pd.iSeconds = -1;
pd.lpActions = pmpd->pa;
// set color of popup
switch (pMsgBox->uType & MB_ICONMASK) {
case MB_ICON_ERROR:
pd.colorBack = RGB(200, 10, 0);
pd.colorText = RGB(255, 255, 255);
break;
case MB_ICON_WARNING:
pd.colorBack = RGB(200, 100, 0);
pd.colorText = RGB(255, 255, 255);
break;
default:
if (pMsgBox->uType & MB_CUSTOMCOLOR) {
pd.colorBack = pMsgBox->colorBack;
pd.colorText = pMsgBox->colorText;
}
}
// handle for MakePopupAction
pmpd->hDialog = hDlg;
// active buttons
switch (MB_TYPE(pMsgBox->uType)) {
case MB_OK:
MakePopupAction(pmpd->pa[pd.actionCount++], IDOK);
break;
case MB_OKCANCEL:
MakePopupAction(pmpd->pa[pd.actionCount++], IDOK);
MakePopupAction(pmpd->pa[pd.actionCount++], IDCANCEL);
break;
case MB_RETRYCANCEL:
MakePopupAction(pmpd->pa[pd.actionCount++], IDRETRY);
MakePopupAction(pmpd->pa[pd.actionCount++], IDCANCEL);
break;
case MB_YESNO:
MakePopupAction(pmpd->pa[pd.actionCount++], IDYES);
MakePopupAction(pmpd->pa[pd.actionCount++], IDNO);
break;
case MB_ABORTRETRYIGNORE:
MakePopupAction(pmpd->pa[pd.actionCount++], IDABORT);
MakePopupAction(pmpd->pa[pd.actionCount++], IDRETRY);
MakePopupAction(pmpd->pa[pd.actionCount++], IDIGNORE);
break;
case MB_YESNOCANCEL:
MakePopupAction(pmpd->pa[pd.actionCount++], IDYES);
MakePopupAction(pmpd->pa[pd.actionCount++], IDNO);
MakePopupAction(pmpd->pa[pd.actionCount++], IDCANCEL);
break;
case MB_YESALLNO:
MakePopupAction(pmpd->pa[pd.actionCount++], IDYES);
MakePopupAction(pmpd->pa[pd.actionCount++], IDALL);
MakePopupAction(pmpd->pa[pd.actionCount++], IDNO);
break;
}
// create popup
CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&pd, APF_NEWDATA);
if (MB_TYPE(pMsgBox->uType) == MB_OK)
EndDialog(hDlg, IDOK);
}
break;
}
return FALSE;
}
示例10: ASSERT
void CAxRectTracker::Construct()
{
// do one-time initialization if necessary
static BOOL bInitialized;
if (!bInitialized)
{
// sanity checks for assumptions we make in the code
ASSERT(sizeof(((RECT*)NULL)->left) == sizeof(int));
ASSERT(offsetof(RECT, top) > offsetof(RECT, left));
ASSERT(offsetof(RECT, right) > offsetof(RECT, top));
ASSERT(offsetof(RECT, bottom) > offsetof(RECT, right));
if (s_afxHatchBrush == NULL)
{
// create the hatch pattern + bitmap
WORD hatchPattern[8];
WORD wPattern = 0x1111;
for (int i = 0; i < 4; i++)
{
hatchPattern[i] = wPattern;
hatchPattern[i+4] = wPattern;
wPattern <<= 1;
}
HBITMAP hatchBitmap = CreateBitmap(8, 8, 1, 1, &hatchPattern);
if (hatchBitmap == NULL)
{
AfxThrowResourceException();
}
// create black hatched brush
s_afxHatchBrush = CreatePatternBrush(hatchBitmap);
DeleteObject(hatchBitmap);
if (s_afxHatchBrush == NULL)
{
AfxThrowResourceException();
}
}
if (s_afxBlackDottedPen == NULL)
{
// create black dotted pen
s_afxBlackDottedPen = CreatePen(PS_DOT, 0, RGB(0, 0, 0));
if (s_afxBlackDottedPen == NULL)
{
AfxThrowResourceException();
}
}
// Note: all track cursors must live in same module
//[B0000] HINSTANCE hInst = AfxFindResourceHandle(MAKEINTRESOURCE(AFX_IDC_TRACK4WAY), RT_GROUP_CURSOR);
// initialize the cursor array
//[B0000] s_afxCursors[0] = ::LoadCursor(hInst, MAKEINTRESOURCE(AFX_IDC_TRACKNWSE));
//[B0000] s_afxCursors[1] = ::LoadCursor(hInst, MAKEINTRESOURCE(AFX_IDC_TRACKNESW));
s_afxCursors[0] = ::LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENWSE)); //[B0000]
s_afxCursors[1] = ::LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENESW)); //[B0000]
s_afxCursors[2] = s_afxCursors[0];
s_afxCursors[3] = s_afxCursors[1];
// s_afxCursors[4] = ::LoadCursor(hInst, MAKEINTRESOURCE(AFX_IDC_TRACKNS));
// s_afxCursors[5] = ::LoadCursor(hInst, MAKEINTRESOURCE(AFX_IDC_TRACKWE));
s_afxCursors[4] = ::LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENS));
s_afxCursors[5] = ::LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZEWE));
s_afxCursors[6] = s_afxCursors[4];
s_afxCursors[7] = s_afxCursors[5];
// s_afxCursors[8] = ::LoadCursor(hInst, MAKEINTRESOURCE(AFX_IDC_TRACK4WAY));
// s_afxCursors[9] = ::LoadCursor(hInst, MAKEINTRESOURCE(AFX_IDC_MOVE4WAY));
s_afxCursors[8] = ::LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZEALL));
s_afxCursors[9] = ::LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZEALL));
// get default handle size from Windows profile setting
static const TCHAR szWindows[] = _T("windows");
static const TCHAR szInplaceBorderWidth[] = _T("oleinplaceborderwidth");
s_afxHandleSize = GetProfileInt(szWindows, szInplaceBorderWidth, 4);
bInitialized = TRUE;
}
m_nStyle = 0;
m_nHandleSize = s_afxHandleSize;
m_sizeMin.cy = m_sizeMin.cx = m_nHandleSize * 2;
m_rectLast.SetRectEmpty();
m_sizeLast.cx = m_sizeLast.cy = 0;
m_bErase = FALSE;
m_bFinalErase = FALSE;
}
示例11: VERIFY
///////////////////////////////////////////////////////////////////////////
// CAxRectTracker operations
void CAxRectTracker::Draw(CDC* pDC) const
{
// set initial DC state
VERIFY(pDC->SaveDC() != 0);
pDC->SetMapMode(MM_TEXT);
pDC->SetViewportOrg(0, 0);
pDC->SetWindowOrg(0, 0);
// get normalized rectangle
CRect rect = m_rect;
rect.NormalizeRect();
CPen* pOldPen = NULL;
CBrush* pOldBrush = NULL;
CGdiObject* pTemp = NULL;
int nOldROP;
// draw lines
if ((m_nStyle & (dottedLine | solidLine)) != 0)
{
if (m_nStyle & dottedLine)
pOldPen = pDC->SelectObject(CPen::FromHandle(s_afxBlackDottedPen));
else
pOldPen = (CPen*)pDC->SelectStockObject(BLACK_PEN);
pOldBrush = (CBrush*)pDC->SelectStockObject(NULL_BRUSH);
nOldROP = pDC->SetROP2(R2_COPYPEN);
rect.InflateRect(+1, +1); // borders are one pixel outside
pDC->Rectangle(rect.left, rect.top, rect.right, rect.bottom);
pDC->SetROP2(nOldROP);
}
// if hatchBrush is going to be used, need to unrealize it
if ((m_nStyle & (hatchInside | hatchedBorder)) != 0)
UnrealizeObject(s_afxHatchBrush);
// hatch inside
if ((m_nStyle & hatchInside) != 0)
{
pTemp = pDC->SelectStockObject(NULL_PEN);
if (pOldPen == NULL) pOldPen = (CPen*)pTemp;
pTemp = pDC->SelectObject(CBrush::FromHandle(s_afxHatchBrush));
if (pOldBrush == NULL) pOldBrush = (CBrush*)pTemp;
pDC->SetBkMode(TRANSPARENT);
nOldROP = pDC->SetROP2(R2_MASKNOTPEN);
pDC->Rectangle(rect.left+1, rect.top+1, rect.right, rect.bottom);
pDC->SetROP2(nOldROP);
}
// draw hatched border
if ((m_nStyle & hatchedBorder) != 0)
{
pTemp = pDC->SelectObject(CBrush::FromHandle(s_afxHatchBrush));
if (pOldBrush == NULL) pOldBrush = (CBrush*)pTemp;
pDC->SetBkMode(OPAQUE);
CRect rectTrue;
GetTrueRect(&rectTrue);
pDC->PatBlt(rectTrue.left, rectTrue.top, rectTrue.Width(),
rect.top-rectTrue.top, 0x000F0001 /* Pn */);
pDC->PatBlt(rectTrue.left, rect.bottom,
rectTrue.Width(), rectTrue.bottom-rect.bottom, 0x000F0001 /* Pn */);
pDC->PatBlt(rectTrue.left, rect.top, rect.left-rectTrue.left,
rect.Height(), 0x000F0001 /* Pn */);
pDC->PatBlt(rect.right, rect.top, rectTrue.right-rect.right,
rect.Height(), 0x000F0001 /* Pn */);
}
// draw resize handles
if ((m_nStyle & (resizeInside | resizeOutside)) != 0)
{
UINT mask = GetHandleMask();
for (int i = 0; i < 8; ++i)
{
if (mask & (1<<i))
{
GetHandleRect((TrackerHit)i, &rect);
pDC->FillSolidRect(rect, RGB(0, 0, 0));
}
}
}
// cleanup pDC state
if (pOldPen != NULL) pDC->SelectObject(pOldPen);
if (pOldBrush != NULL) pDC->SelectObject(pOldBrush);
VERIFY(pDC->RestoreDC(-1));
}
示例12: WinProc
//.........这里部分代码省略.........
120,
150,
190,
25,
hWnd,
(HMENU)INPUT_TEXT_ADD_FOOD,
GetModuleHandle(NULL),
NULL);
}
break;
case WM_PAINT: {
HDC hdc = BeginPaint(hWnd, &Ps);
RECT rect;
/**
* Draw Text
*/
// Second Text
char foodNrMessage[256] = "Number : ";
char nr[50];
strcat(foodNrMessage, itoa(foodNumber, nr, 10));
SetBkMode(hdc, TRANSPARENT);
SetRect(&updateRect, 210, 10, 300, 30);
DrawText( hdc, foodNrMessage, -1, &updateRect, DT_SINGLELINE | DT_NOCLIP ) ;
// First Text
HFONT hFont = CreateFont(25,0,0,0,FW_DONTCARE,FALSE,TRUE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS,
CLIP_DEFAULT_PRECIS,NULL, VARIABLE_PITCH,TEXT("Impact"));
SetRect(&rect, 10, 10, 50, 50);
SelectObject(hdc, hFont);
SetBkMode(hdc, OPAQUE);
SetBkColor(hdc, RGB(0,255,255));
SetTextColor(hdc, RGB(255,0,0));
DrawText(hdc, TEXT(firstText), -1,&rect, DT_NOCLIP);
EndPaint(hWnd, &Ps);
}
break;
case WM_CTLCOLOREDIT: {
HDC hdc = (HDC)wParam;
HWND hwnd = (HWND)lParam;
HBRUSH color;
if (GetDlgCtrlID(hwnd) == INPUT_TEXT_ADD_FOOD) {
color = CreateSolidBrush(RGB(225, 225, 225));
SetTextColor(hdc, RGB(0, 0, 255));
SetBkMode(hdc, TRANSPARENT);
SetBkColor(hdc,(LONG)color);
}
return (LONG) color;
}
break;
case WM_COMMAND: {
switch(LOWORD(wParam)) {
case BUTTON_ADD_FOOD: {
char buffer[256];
SendMessage(hInputFood,
WM_GETTEXT,
sizeof(buffer)/sizeof(buffer[0]),
reinterpret_cast<LPARAM>(buffer));
示例13: AddBoolProperty
void CDynControl::PrepareDataArray()
{
if(IsNew==0)
return;
IsNew=0;
csPropertyName="Основные";
if(m_nControlType == ID_DYNBUTTONTREE)//TREE
{
csPropertyName="Дерево";
AddBoolProperty("Есть кнопки",1);
AddBoolProperty("Есть линии",1);
AddBoolProperty("Есть корневая линия",1);
AddBoolProperty("Есть пиктограммы",0);
AddStringProperty("Тип значения",nTypeValue,"ДеревоЗначений");
AddFuncProperty("Выбор",NM_DBLCLK,"");
AddFuncProperty("Выделение",TVN_SELCHANGED,"");
AddFuncProperty("Откр. ветки",TVN_ITEMEXPANDED,"");
AddFuncProperty("Нажатие клавиши",WM_KEYDOWN,"");
}
else
if(m_nControlType == ID_DYNBUTTONGRID)//GRID
{
csPropertyName="Grid";
AddIntProperty("Число строк",20);
AddIntProperty("Число колонок",10);
AddIntProperty("Число фикс.стр",1);
AddIntProperty("Число фикс.кол.",1);
AddBoolProperty("Разрешить редактирование",1);
AddBoolProperty("",1);
AddBoolProperty("",1);
// AddBoolProperty("Выделять фикс.колонки",1);//5
// AddBoolProperty("Выделять фикс.строки",1);
AddBoolProperty("Сортировка колонок",1);
AddIntProperty("Высота ячейки",16);
AddIntProperty("Ширина ячейки",130);
AddBoolProperty("",1);
// AddBoolProperty("Выделение строки",1);//10
AddBoolProperty("Авторазмер колонок",0);
AddBoolProperty("Виртуальный режим",0);
AddColorProperty("Цвет фона таблицы",RGB(255,255,255));
AddStringProperty("Тип значения",nTypeValue,csPropertyName);
AddFuncProperty("Начало редактирования",GVN_BEGINLABELEDIT,"");
AddFuncProperty("Двойн.лев.кнопка",NM_DBLCLK,"");
AddFuncProperty("Левая кнопка",NM_CLICK,"");
AddFuncProperty("Правая кнопка",NM_RCLICK,"");
AddFuncProperty("Окончание редактирования",GVN_ENDLABELEDIT,"");
AddFuncProperty("Начало выделения",GVN_SELCHANGING,"");
AddFuncProperty("Окончание выделения",GVN_SELCHANGED,"");
AddFuncProperty("Нажатие клавиши",WM_KEYDOWN,"");
AddFuncProperty("Обратный вызов виртуального режима",9999,"");
}
else
if (m_nControlType == ID_DYNBUTTONEDIT) // EDIT
{
csPropertyName="Реквизит диалога";
AddStringProperty("Тип значения",nTypeValue,"Строка");
AddBoolProperty("Неограниченная длина",1);
AddIntProperty("Длина",10);
AddIntProperty("Точность",0);
AddBoolProperty("Неотрицательный",0);//4
AddBoolProperty("Многострочный",0);
AddBoolProperty("Ввод пароля",0);
AddBoolProperty("Кнопка выбора",0);//7
AddBoolProperty("Запретить редактирование",0);//8
AddFuncProperty("Выбор",WM_ONSELECT,"");
AddFuncProperty("Редактирование",EN_CHANGE,"");
AddFuncProperty("Нажатие клавиши",WM_KEYDOWN,"");
}
else
if (m_nControlType == ID_DYNBUTTONRADIO) // RADIO
{
csPropertyName="Переключатель";
AddBoolProperty("Первый в группе",0);
AddStringProperty("Тип значения",nTypeValue,"");
AddFuncProperty("Выбор",BN_CLICKED,"");
AddFuncProperty("Нажатие клавиши",WM_KEYDOWN,"");
}
else
if (m_nControlType == ID_DYNBUTTONLISTBOX) // LISTBOX
{
csPropertyName="Список";
AddBoolProperty("Мультивыделение строк",0);
AddStringProperty("Тип значения",nTypeValue,"СписокЗначений");
AddFuncProperty("Выбор",LBN_DBLCLK,"");
AddFuncProperty("Позиционирование",LBN_SELCHANGE,"");
//LBN_SELCANCEL
AddFuncProperty("Нажатие клавиши",WM_KEYDOWN,"");
}
else
if (m_nControlType == ID_DYNBUTTONLABEL) // LABEL
//.........这里部分代码省略.........
示例14: sprintf
void KMyCanvas::OnDraw(HDC hDC, const RECT * rcPaint)
{
if ( m_lastlimit>= m_limit )
return;
TCHAR title [MAX_PATH];
sprintf(title, "Mandelbrot Set (%f %f) zoom %d:%d unit %f", m_x, m_y, m_zoommul, m_zoomdiv, m_unit);
SetWindowText(GetParent(m_hWnd), title);
int tick = GetTickCount();
if ( rcPaint )
m_lastlimit = 0;
RECT rect;
GetClientRect(m_hWnd, & rect);
int x0 = GetScrollPos(m_hWnd, SB_HORZ);
int y0 = GetScrollPos(m_hWnd, SB_VERT);
// ClearBuffer(rect.right, rect.bottom, x0, y0);
HRGN hRgn = CreateRectRgn(0, 0, 1, 1);
{
GetRandomRgn(hDC, hRgn, SYSRGN);
POINT p0;
GetDCOrgEx(hDC, & p0);
// change region to be relative to DC, NT only
// if ( HIWORD(hDC) )
OffsetRgn(hRgn, - p0.x, - p0.y);
}
m_lastlimit += 16;
for (int y=0; y<rect.bottom; y++)
{
COLORREF lastc = 0xFFFFFFFF;
int count = 0;
for (int x=0; x<rect.right; x++)
// if ( Buffer[y][x]==0 )
if ( PtInRegion(hRgn, x, y) )
{
int count = MandelCount(NULL, x+x0, y+y0, m_limit);
COLORREF c = 0;
if ( count==0 ) // don't know
c = RGB(64, 78, 170); // Red
else if ( count>0 ) // yes
c = In[count]; // green
else if ( count< -3 )
c = Out[-count];
// Buffer[y][x] = count;
if ( c )
SetPixel(hDC, x+x0, y+y0, c);
}
}
tick = GetTickCount() - tick;
wsprintf(title, "tick %d", tick);
m_pStatus->SetText(1, title);
}
示例15: OnPaint
LRESULT OnPaint(HWND hWnd,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
int idx;
HPEN hPen,hOldPen;
HBRUSH hBrush,hOldBrush;
RECT crt;
HDC hMemDC;
HBITMAP hOldBitmap;
int x,y;
hdc=BeginPaint(hWnd, &ps);
hMemDC=CreateCompatibleDC(hdc);
GetClientRect(hWnd,&crt);
if (hBackBit == NULL) {
hBackBit=CreateCompatibleBitmap(hdc,crt.right,crt.bottom);
}
hOldBitmap=(HBITMAP)SelectObject(hMemDC,hBackBit);
FillRect(hMemDC,&crt,GetSysColorBrush(COLOR_WINDOW));
if (bGridLine) {
hPen=CreatePen(PS_SOLID,1,RGB(192,192,192));
hOldPen=(HPEN)SelectObject(hMemDC,hPen);
for (y=0;y<crt.bottom;y=y+GridLineY*GridY) {
MoveToEx(hMemDC,0,y,NULL);
LineTo(hMemDC,crt.right,y);
}
for (x=0;x<crt.right;x=x+GridLineX*GridX) {
MoveToEx(hMemDC,x,0,NULL);
LineTo(hMemDC,x,crt.bottom);
}
DeleteObject(SelectObject(hMemDC,hOldPen));
}
for (idx=0;idx<arNum;idx++) {
if (arObj[idx]->LineColor == (COLORREF)-1) {
hPen=(HPEN)GetStockObject(NULL_PEN);
} else {
hPen=CreatePen(PS_INSIDEFRAME,arObj[idx]->LineWidth,arObj[idx]->LineColor);
}
hOldPen=(HPEN)SelectObject(hMemDC,hPen);
if (arObj[idx]->PlaneColor == (COLORREF)-1) {
hBrush=(HBRUSH)GetStockObject(NULL_BRUSH);
} else {
hBrush=CreateSolidBrush(arObj[idx]->PlaneColor);
}
hOldBrush=(HBRUSH)SelectObject(hMemDC,hBrush);
switch (arObj[idx]->Type) {
case DT_LINE:
if ((arObj[idx]->Flag & 0x3) == DS_LT || (arObj[idx]->Flag & 0x3) == DS_RB) {
MoveToEx(hMemDC,arObj[idx]->rt.left,arObj[idx]->rt.top,NULL);
LineTo(hMemDC,arObj[idx]->rt.right,arObj[idx]->rt.bottom);
} else {
MoveToEx(hMemDC,arObj[idx]->rt.left,arObj[idx]->rt.bottom,NULL);
LineTo(hMemDC,arObj[idx]->rt.right,arObj[idx]->rt.top);
}
break;
case DT_ELLIPSE:
Ellipse(hMemDC,arObj[idx]->rt.left,arObj[idx]->rt.top,
arObj[idx]->rt.right,arObj[idx]->rt.bottom);
break;
case DT_RECTANGLE:
Rectangle(hMemDC,arObj[idx]->rt.left,arObj[idx]->rt.top,
arObj[idx]->rt.right,arObj[idx]->rt.bottom);
break;
}
SelectObject(hMemDC,hOldPen);
SelectObject(hMemDC,hOldBrush);
if (arObj[idx]->LineColor != (COLORREF)-1) {
DeleteObject(hPen);
}
if (arObj[idx]->PlaneColor != (COLORREF)-1) {
DeleteObject(hBrush);
}
}
if (NowSel != -1) {
DrawTracker(hMemDC,NowSel);
}
BitBlt(hdc,0,0,crt.right,crt.bottom,hMemDC,0,0,SRCCOPY);
SelectObject(hMemDC,hOldBitmap);
DeleteDC(hMemDC);
EndPaint(hWnd, &ps);
return 0;
}