void MarketMakerDlg::FillLevel1() { CString str; char num[33]; switch(B_GetBidTickStatus(m_level1)) { case NOTICK: str = "NO"; break; case UPTICK: str = "UP"; break; case DOWNTICK: str = "DOWN"; break; } m_l1BidTick.SetWindowText(str); _i64toa_s(B_GetVolume(m_level1), num, sizeof(num), 10); m_l1Volume.SetWindowText(num); CTime t(B_GetLastTradeTime(m_level1)); m_l1Time.SetWindowText(t.Format("%H:%M:%S")); _ultoa_s(B_GetLastTrade(m_level1).GetSize(), num, sizeof(num), 10); m_l1Size.SetWindowText(num); str = ""; ExtFrame::FormatMoney(str, B_GetOpenPrice(m_level1)); m_l1Open.SetWindowText(str); str = ""; ExtFrame::FormatMoney(str, B_GetNetChange(m_level1)); m_l1Net.SetWindowText(str); str = ""; ExtFrame::FormatMoney(str, B_GetIntraDayLow(m_level1)); m_l1Lo.SetWindowText(str); str = ""; ExtFrame::FormatMoney(str, B_GetLastTrade(m_level1)); m_l1Last.SetWindowText(str); str = ""; ExtFrame::FormatMoney(str, B_GetIntraDayHigh(m_level1)); m_l1Hi.SetWindowText(str); str = ""; ExtFrame::FormatMoney(str, B_GetClosePrice(m_level1)); m_l1Close.SetWindowText(str); _ultoa_s(B_GetBid(m_level1).GetSize(), num, sizeof(num), 10); str = num; str += "x"; _ultoa_s(B_GetAsk(m_level1).GetSize(), num, sizeof(num), 10); str += num; m_l1BXA.SetWindowText(str); }
void ExtFrame::OnOrders() { // TODO: Add your command handler code here Observable* account = B_GetCurrentAccount(); if(!account) { return; } CString str; char num[33]; void* iterator = B_CreateOrderIterator(OS_CANCELLED|OS_FILLED|OS_PENDINGLONG|OS_PENDINGSHORT,(1 << ST_LAST) - 1, account); B_StartIteration(iterator); const Order* order; while(order = B_GetNextOrder(iterator)) { str += "\n"; str += order->GetSymbol(); str += " Id="; _ultoa_s(order->GetId(), num, sizeof(num), 10); str += num; str += " Side="; str += order->GetSide(); str += " P&&L="; FormatMoney(str, order->GetPnl()); str += " Market="; str += order->GetDestination(); str += " Contra="; str += order->GetCounterparty(); str += " Price="; FormatMoney(str, *order); str += " Size="; _ultoa_s(order->GetSize(), num, sizeof(num), 10); str += num; str += " ExecPrice="; FormatMoney(str, order->GetExecutedPrice()); str += " ExecSize="; _ultoa_s(order->GetExecutedSize(), num, sizeof(num), 10); str += num; str += " Pending="; _ultoa_s(order->GetRemainingSize(), num, sizeof(num), 10); str += num; str += " Confirmed="; str += order->isConfirmed() ? "Yes" : "No"; str += " BeingCanceled="; str += order->isBeingCanceled() ? "Yes" : "No"; str += " MarketOrder="; str += order->isMarketOrder() ? "Yes" : "No"; /* time_t GetTimeCanceled() const{return m_timeCanceled;} unsigned int GetTimeInForce() const{return m_tif;} virtual void Cancel() = 0; */ } B_DestroyIterator(iterator); AfxGetMainWnd()->MessageBox(str, "Orders", MB_OK); }
void ExtFrame::FormatTif(unsigned int tif, std::string& text) { switch(tif) { case TIF_IOC: text = "IOC"; break; case TIF_ISLAND_DAY: text = "Day"; break; case TIF_ISLAND_EXTENDED_DAY: text = "Ext"; break; case TIF_GTC: text = "GTC"; break; case TIF_OPENING: text = "OPEN"; break; case TIF_DAY: text = "DAY"; break; default: { char num[33]; unsigned int hours = tif / 3600; tif -= 3600 * hours; unsigned int minutes = tif / 60; tif -= 60 * minutes; text = ""; if(hours) { if(hours < 10) { text += '0'; } _ultoa_s(hours, num, sizeof(num), 10); text += num; text += ':'; } if(minutes) { FormatTimeToken(minutes, text); text += ':'; } else if(hours) { text += "00:"; } FormatTimeToken(tif, text); } break; } }
string ToStr(unsigned long num, int base) { char str[MAX_DIGITS_IN_INT]; memset(str,0,MAX_DIGITS_IN_INT); _ultoa_s(num,str,MAX_DIGITS_IN_INT,base); return (string(str)); }
void ExtFrame::IncrementSpin(CSpinButtonCtrl& spin, CEdit& edit, unsigned int val) { char num[33]; _ultoa_s(val, num, sizeof(num), 10); spin.SetPos(val); edit.SetWindowText(num); ScrollEnd(edit); }
String& String::operator+=(size_t number) { char buffer[65]; // an int will never take more than 65 characters (int64 is max 20 characters) _ultoa_s((unsigned long) number, buffer, sizeof(buffer), 10); return *this += String(buffer); }
std::string str(uint32_t value) { char buf[64]; #ifdef USING_VISUAL_2005 if (_ultoa_s(value, buf, sizeof(buf), 10) == 0) return buf; else return ""; #else return _ultoa(value, buf, 10); #endif //USING_VISUAL_2005 }
unsigned int ExtFrame::SetDollarsAndCents(CSpinButtonCtrl& spinDollars, CEdit& editDollars, CSpinButtonCtrl& spinCents, CEdit& editCents, unsigned int val, unsigned int maxDollars) { spinDollars.SetRange(0, maxDollars); spinCents.SetRange(0, 99); char num[33]; _ultoa_s(maxDollars, num, sizeof(num), 10); editDollars.SetLimitText((unsigned int)strlen(num)); editCents.SetLimitText(2); unsigned int dollars = val / 1000; SetSpinValue(spinDollars, editDollars, dollars, false); unsigned int tenthcents = val - 1000 * dollars; unsigned int cents = tenthcents / 10; SetSpinValue(spinCents, editCents, cents, true); return tenthcents - 10 * cents; }
void MarketMakerDlg::FillPrints() { const Transaction* t; unsigned int entries = (unsigned int)m_prints.size(); unsigned int count = 0; char num[33]; CString str; B_StartIteration(m_printsIterator); while((t = B_GetNextPrintsEntry(m_printsIterator)) && count < entries) { str = ""; // ExtFrame::FormatDollarsAndCents(str, t->GetPriceWhole(), t->GetPriceThousandsFraction()); ExtFrame::FormatMoney(str, *t); str += " "; _ultoa_s(t->GetSize(), num, sizeof(num), 10); str += num; str += " "; CTime t(t->GetTime()); str += t.Format("%H:%M:%S"); /* switch(t->GetStatus()) { case TRADE_GREATERTHANASK: case TRADE_LESSTHANBID: break; default: break; } */ m_prints[count]->SetWindowText(str); count++; } for(; count < entries; count++) { m_prints[count]->SetWindowText(""); } }
void TakeScreenshot() { if(RealDevice==NULL) return; HRESULT hr; IDirect3DSurface* surface; RECT r; RECT* pRect=0; //#ifndef RELEASE // hr=RealDevice->CreateOffscreenPlainSurface(1280,1024, // D3DFMT_A8R8G8B8,D3DPOOL_SCRATCH,&surface,NULL); //#else DWORD width, height; if(JointInfo.WNDwindowed) { D3DDISPLAYMODE mode; RealDevice->GetDisplayMode(0, &mode); hr=RealDevice->CreateOffscreenPlainSurface(mode.Width,mode.Height,D3DFMT_A8R8G8B8,D3DPOOL_SCRATCH,&surface,NULL); HWND win=FindWindow("morrowind", "morrowind"); //GetWindowRect(win, &r); POINT p; p.x = 0; p.y = 0; ClientToScreen(win, &p); GetClientRect(win, &r); r.left += p.x; r.top += p.y; r.right += p.x; r.bottom += p.y; if(r.left < 0) r.left = 0; if(r.top < 0) r.top = 0; if((UINT)r.right >= mode.Width) r.right = (LONG)mode.Width - 1; if((UINT)r.bottom >= mode.Height) r.bottom = (LONG)mode.Height - 1; pRect=&r; width=mode.Width; height=mode.Height; } else { width=JointInfo.GraphicsWidth; height=JointInfo.GraphicsHeight; hr=RealDevice->CreateOffscreenPlainSurface(JointInfo.GraphicsWidth,JointInfo.GraphicsHeight, D3DFMT_A8R8G8B8,D3DPOOL_SCRATCH,&surface,NULL); } //#endif if(hr!=D3D_OK) return; hr=RealDevice->GetFrontBufferData(0,surface); if(hr==D3D_OK) { D3DLOCKED_RECT rect2; hr=surface->LockRect(&rect2, 0, 0); if(hr==D3D_OK&&!(rect2.Pitch%4)) { DWORD *ptr=(DWORD*)rect2.pBits; rect2.Pitch/=4; for(DWORD y=0;y<height;y++) { DWORD offset=y*rect2.Pitch; for(DWORD x=0;x<width;x++) { ptr[offset+x]|=0xff000000; } } surface->UnlockRect(); } char FileNameEnds[40]=".bmp\0\0\0\0.jpg\0\0\0\0.dds\0\0\0\0.png\0\0\0\0.tga\0\0\0"; char FileNameEnd[8]; char FileNameStart[240]; char FileName[256]; char Number[6]; FileNameStart[0] = '\0'; struct _stat64i32 unused; if (strlen(SSDir) > 0) { bool usedir = true; if (_stat64i32(SSDir, &unused) == -1 && !CreateDirectory(SSDir, NULL)) usedir = false; if (usedir) { strcat_s(FileNameStart, 240, SSDir); strcat_s(FileNameStart, 240, "\\"); } } strcat_s(FileNameStart, 240, SSName); for (int i = 0; i < 8; ++i) FileNameEnd[i] = FileNameEnds[i + SSFormat * 8]; for (unsigned long ui = 1; ui <= 99999; ++ui) { FileName[0] = '\0'; strcat_s(FileName, 256, FileNameStart); char* FNamEnd = FileName + strlen(FileName); _ultoa_s(ui, Number, 6, 10); for (int i = strlen(Number); i < SSMinNumChars; ++i) *(FNamEnd++) = '0'; *FNamEnd = '\0'; strcat_s(FileName, 256, Number); strcat_s(FileName, FileNameEnd); if (_stat64i32(FileName, &unused) == -1) { switch (SSFormat) { case 0: hr = D3DXSaveSurfaceToFile(FileName, D3DXIFF_BMP, surface, NULL, pRect); break; case 1: hr = D3DXSaveSurfaceToFile(FileName, D3DXIFF_JPG, surface, NULL, pRect); break; case 2: hr = D3DXSaveSurfaceToFile(FileName, D3DXIFF_DDS, surface, NULL, pRect); break; case 3: hr = D3DXSaveSurfaceToFile(FileName, D3DXIFF_PNG, surface, NULL, pRect); break; case 4: hr = D3DXSaveSurfaceToFile(FileName, D3DXIFF_TGA, surface, NULL, pRect); break; default: hr = -1; } break; } } } if(hr == D3D_OK) { SETSTATUS("Screen shot saved"); } else { SETSTATUS("Screen shot failed"); } surface->Release(); }