本文整理汇总了C++中CButton::SetButton方法的典型用法代码示例。如果您正苦于以下问题:C++ CButton::SetButton方法的具体用法?C++ CButton::SetButton怎么用?C++ CButton::SetButton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CButton
的用法示例。
在下文中一共展示了CButton::SetButton方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawString
void CMenu::DrawString(char *szText, int length, int x, int y, CItem *pItem, void (*function)())
{
// This is where we use our font image to display text to the screen. We need to
// go through every character and index that character into our font image.
for(int i = 0; i < length; i++)
{
// Here we get the index into our font image. We minus 32 since our font image
// isn't set up from ASCII characters 0-32, they are ommitted (smiley faces, etc...).
int index = (int)(szText[i]-32);
int xOffset = (index % kCharPerLine) * kFontWidth;
int charY = (index / kCharPerLine) * kFontHeight;
// Next we grab the RECT offset into the font bitmap, then display that character
RECT rCharacter = {xOffset, charY, xOffset + kFontWidth, charY + kFontHeight};
g_Buffer.DisplayTransparentBitmap(m_fontImage, x + i*kFontWidth, y, rCharacter);
}
// If there is no data for a button, don't create one and return
if(!function && !pItem) return;
// Create a button with an associated item or function for that button.
// We then want to add it to our vector button list.
CButton button;
button.SetButton(szText, length * kFontWidth, x, y, pItem, function);
m_vButtons.push_back(button);
}
示例2: DrawString
void CMenu::DrawString(char *szText, int length, int x, int y, CItem *pItem, void (*function)())
{
// Set the string colors to white text and a blue background
WORD dialogColor = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY |
BACKGROUND_BLUE | BACKGROUND_INTENSITY;
HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD dwResult = 0;
COORD position = {x, y};
// Draw the text to the screen and fill the text with it's attribute
WriteConsoleOutputCharacter(hOutput, szText, length, position, &dwResult);
FillConsoleOutputAttribute(hOutput, dialogColor, length, position, &dwResult);
// If there is no data for a button, don't create one and return
if(!function && !pItem) return;
// Create a button with an associated item or function for that button.
// We then want to add it to our vector button list.
CButton button;
button.SetButton(szText, length, x, y, pItem, function);
m_vButtons.push_back(button);
}