本文整理汇总了C++中SetContext函数的典型用法代码示例。如果您正苦于以下问题:C++ SetContext函数的具体用法?C++ SetContext怎么用?C++ SetContext使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetContext函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawFileStrings
static void
DrawFileStrings (MELEE_STATE *pMS)
{
POINT origin;
CONTEXT OldContext;
origin.x = FILE_STRING_ORIGIN_X;
origin.y = FILE_STRING_ORIGIN_Y;
OldContext = SetContext (SpaceContext);
SetContextFont (MicroFont);
BatchGraphics ();
DrawMeleeIcon (28); /* The load team frame */
if (FillFileView (pMS))
{
COUNT i;
for (i = pMS->load.top; i < pMS->load.bot; i++) {
DrawFileString (pMS->load.view[i - pMS->load.top], &origin,
TRUE, FALSE);
origin.y += ENTRY_HEIGHT;
}
}
UnbatchGraphics ();
SetContext (OldContext);
}
示例2: GetContext
/// <summary>
/// Remove existing hardware breakpoint
/// </summary>
/// <param name="ptr">Breakpoint address</param>
/// <returns>true on success</returns>
bool Thread::RemoveHWBP( ptr_t ptr )
{
_CONTEXT64 context64 = { 0 };
_CONTEXT32 context32 = { 0 };
bool use64 = !_core->native()->GetWow64Barrier().x86OS;
bool res = use64 ? GetContext( context64, CONTEXT64_DEBUG_REGISTERS, true ) : GetContext( context32, CONTEXT_DEBUG_REGISTERS, true );
auto pDR7 = use64 ? reinterpret_cast<regDR7*>(&context64.Dr7) : reinterpret_cast<regDR7*>(&context32.Dr7);
if (!res)
return false;
// Search for breakpoint
for (int i = 0; i < 4; i++)
{
if ((&context64.Dr0)[i] == ptr || (&context32.Dr0)[i] == static_cast<DWORD>(ptr))
{
use64 ? *(&context64.Dr0 + i) = 0 : *(&context32.Dr0 + i) = 0;
pDR7->setLocal( i, 0 );
pDR7->setLen( i, 0 );
pDR7->setRW( i, 0 );
if (pDR7->empty())
pDR7->l_enable = 0;
return use64 ? SetContext( context64 ) : SetContext( context32 );
}
}
return false;
}
示例3: BuildPickMeleeFrame
// Create a frame for each player to display their current fleet in,
// to be used when selecting the next ship to fight with.
void
BuildPickMeleeFrame (void)
{
STAMP s;
CONTEXT OldContext = SetContext (OffScreenContext);
if (PickMeleeFrame)
DestroyDrawable (ReleaseDrawable (PickMeleeFrame));
PickMeleeFrame = CaptureDrawable (CreateDrawable (
WANT_PIXMAP, MELEE_WIDTH, MELEE_HEIGHT, 2));
s.origin.x = 0;
s.origin.y = 0;
s.frame = CaptureDrawable (LoadGraphic (MELEE_PICK_MASK_PMAP_ANIM));
SetContextFGFrame (PickMeleeFrame);
DrawStamp (&s);
s.frame = IncFrameIndex (s.frame);
SetContextFGFrame (IncFrameIndex (PickMeleeFrame));
DrawStamp (&s);
DestroyDrawable (ReleaseDrawable (s.frame));
SetContext (OldContext);
}
示例4: DrawCargoStrings
void
DrawCargoStrings (BYTE OldElement, BYTE NewElement)
{
CONTEXT OldContext;
OldContext = SetContext (StatusContext);
SetContextFont (TinyFont);
BatchGraphics ();
if (OldElement > NUM_ELEMENT_CATEGORIES)
{ // Asked for the initial display
DrawCargoDisplay ();
// do not draw unselected again this time
OldElement = NewElement;
}
if (OldElement != NewElement)
{ // unselect the previous element
DrawElementAmount (OldElement, false);
}
if (NewElement != (BYTE)~0)
{ // select the new element
DrawElementAmount (NewElement, true);
}
UnbatchGraphics ();
SetContext (OldContext);
}
示例5: GetContext
/// <summary>
/// Add hardware breakpoint to thread
/// </summary>
/// <param name="addr">Breakpoint address</param>
/// <param name="type">Breakpoint type(read/write/execute)</param>
/// <param name="length">Number of bytes to include into breakpoint</param>
/// <returns>Index of used breakpoint; -1 if failed</returns>
int Thread::AddHWBP( ptr_t addr, HWBPType type, HWBPLength length )
{
_CONTEXT64 context64 = { 0 };
_CONTEXT32 context32 = { 0 };
bool use64 = !_core->native()->GetWow64Barrier().x86OS;
// CONTEXT_DEBUG_REGISTERS can be operated without thread suspension
bool res = use64 ? GetContext( context64, CONTEXT64_DEBUG_REGISTERS, true ) : GetContext( context32, CONTEXT_DEBUG_REGISTERS, true );
auto pDR7 = use64 ? reinterpret_cast<regDR7*>(&context64.Dr7) : reinterpret_cast<regDR7*>(&context32.Dr7);
if (!res)
return -1;
// Get free DR
int freeIdx = pDR7->getFreeIndex();
// If all 4 registers are occupied - error
if (freeIdx < 0)
{
LastNtStatus( STATUS_NO_MORE_ENTRIES );
return -1;
}
// Enable corresponding HWBP and local BP flag
pDR7->l_enable = 1;
pDR7->setLocal( freeIdx, 1 );
pDR7->setRW( freeIdx, static_cast<char>(type) );
pDR7->setLen( freeIdx, static_cast<char>(length) );
use64 ? *(&context64.Dr0 + freeIdx) = addr : *(&context32.Dr0 + freeIdx) = static_cast<DWORD>(addr);
// Write values to registers
res = use64 ? SetContext( context64, true ) : SetContext( context32, true );
return res ? freeIdx : -1;
}
示例6: on_input_frame
static void
on_input_frame (void)
{
CONTEXT oldContext;
oldContext = SetContext (SpaceContext);
animatePowerLines (NULL);
SetContext (oldContext);
}
示例7: DrawOscilloscope
// draws the oscilloscope
void
DrawOscilloscope (void)
{
STAMP s;
BYTE scope_data[128];
if (oscillDisabled)
return;
assert ((size_t)scopeSize.width <= sizeof scope_data);
assert (scopeSize.height < 256);
if (GraphForegroundStream (scope_data, scopeSize.width, scopeSize.height))
{
int i;
CONTEXT oldContext;
oldContext = SetContext (OffScreenContext);
SetContextFGFrame (scopeWork);
SetContextClipRect (NULL);
// draw the background image
s.origin.x = 0;
s.origin.y = 0;
s.frame = scope_frame;
DrawStamp (&s);
// draw the scope lines
SetContextForeGroundColor (scopeColor);
for (i = 0; i < scopeSize.width - 1; ++i)
{
LINE line;
line.first.x = i + 1;
line.first.y = scope_data[i] + 1;
line.second.x = i + 2;
line.second.y = scope_data[i + 1] + 1;
DrawLine (&line);
}
SetContext (oldContext);
s.frame = scopeWork;
}
else
{ // no data -- draw blank scope background
s.frame = scope_frame;
}
// draw the final scope image to screen
s.origin.x = 0;
s.origin.y = 0;
DrawStamp (&s);
}
示例8: putScreen
static void
putScreen (FRAME savedFrame) {
STAMP stamp;
CONTEXT oldContext = SetContext (ScreenContext);
stamp.origin.x = 0;
stamp.origin.y = 0;
stamp.frame = savedFrame;
DrawStamp (&stamp);
(void) SetContext (oldContext);
}
示例9: DoSaveTeam
BOOLEAN
DoSaveTeam (MELEE_STATE *pMS)
{
STAMP MsgStamp;
char file[NAME_MAX];
uio_Stream *stream;
CONTEXT OldContext;
bool saveOk = false;
snprintf (file, sizeof file, "%s.mle",
MeleeSetup_getTeamName (pMS->meleeSetup, pMS->side));
LockMutex (GraphicsLock);
OldContext = SetContext (ScreenContext);
ConfirmSaveLoad (&MsgStamp);
// Show the "Saving . . ." message.
UnlockMutex (GraphicsLock);
stream = uio_fopen (meleeDir, file, "wb");
if (stream != NULL)
{
saveOk = (MeleeTeam_serialize (&pMS->meleeSetup->teams[pMS->side],
stream) == 0);
uio_fclose (stream);
if (!saveOk)
uio_unlink (meleeDir, file);
}
pMS->load.top = 0;
pMS->load.cur = 0;
// Undo the screen damage done by the "Saving . . ." message.
LockMutex (GraphicsLock);
DrawStamp (&MsgStamp);
DestroyDrawable (ReleaseDrawable (MsgStamp.frame));
SetContext (OldContext);
UnlockMutex (GraphicsLock);
if (!saveOk)
SaveProblem ();
// Update the team list; a previously existing team may have been
// deleted when save failed.
LoadTeamList (pMS);
SelectTeamByFileName (pMS, file);
return (stream != 0);
}
示例10: DrawPickMeleeFrame
// Pre: caller holds the graphics lock.
static void
DrawPickMeleeFrame (COUNT which_player)
{
CONTEXT oldContext;
STAMP s;
oldContext = SetContext (SpaceContext);
s.frame = SetAbsFrameIndex (PickMeleeFrame, which_player);
s.origin.x = PICK_X_OFFS - RES_SCALE(3); // JMS_GFX
s.origin.y = PICK_Y_OFFS - RES_SCALE(9) + ((1 - which_player) * PICK_SIDE_OFFS);
DrawStamp (&s);
// Draw the selection box to screen.
SetContext (oldContext);
}
示例11: describeContext
static void
describeContext (FILE *out, const CONTEXT context) {
RECT rect;
CONTEXT oldContext = SetContext (context);
GetContextClipRect (&rect);
fprintf(out, "Context '%s':\n"
"\tClipRect = (%d, %d)-(%d, %d) (%d x %d)\n",
GetContextName (context),
rect.corner.x, rect.corner.y,
rect.corner.x + rect.extent.width,
rect.corner.y + rect.extent.height,
rect.extent.width, rect.extent.height);
SetContext (oldContext);
}
示例12: isContextVisible
// Returns true iff this context has a visible FRAME.
static bool
isContextVisible (CONTEXT context)
{
FRAME contextFrame;
// Save the original context.
CONTEXT oldContext = SetContext (context);
// Get the frame of the specified context.
contextFrame = GetContextFGFrame ();
// Restore the original context.
SetContext (oldContext);
return contextFrame == Screen;
}
示例13: InitSISContexts
void
InitSISContexts (void)
{
RECT r;
SetContext (StatusContext);
SetContext (SpaceContext);
SetContextFGFrame (Screen);
r.corner.x = SIS_ORG_X;
r.corner.y = SIS_ORG_Y;
r.extent.width = SIS_SCREEN_WIDTH;
r.extent.height = SIS_SCREEN_HEIGHT;
SetContextClipRect (&r);
}
示例14: getScreen
// Maybe move to elsewhere, where it can be reused?
static FRAME
getScreen (void)
{
CONTEXT oldContext = SetContext (ScreenContext);
FRAME savedFrame;
RECT screenRect;
screenRect.corner.x = 0;
screenRect.corner.y = 0;
screenRect.extent.width = ScreenWidth;
screenRect.extent.height = ScreenHeight;
savedFrame = CaptureDrawable (LoadDisplayPixmap (&screenRect, (FRAME) 0));
(void) SetContext (oldContext);
return savedFrame;
}
示例15: RosterCleanup
static void
RosterCleanup (MENU_STATE *pMS)
{
if (pMS->flash_task)
{
UnlockMutex (GraphicsLock);
ConcludeTask (pMS->flash_task);
LockMutex (GraphicsLock);
pMS->flash_task = 0;
}
if (pMS->CurFrame)
{
STAMP s;
SHIP_FRAGMENT *StarShipPtr;
SetContext (StatusContext);
s.origin = pMS->first_item;
StarShipPtr = LockShipFrag (&GLOBAL (built_ship_q),
(HSHIPFRAG)pMS->CurFrame);
s.frame = StarShipPtr->icons;
UnlockShipFrag (&GLOBAL (built_ship_q), (HSHIPFRAG)pMS->CurFrame);
if (!(pMS->CurState & SHIP_TOGGLE))
DrawStamp (&s);
else
{
SetContextForeGroundColor (WHITE_COLOR);
DrawFilledStamp (&s);
}
}
}