void SaveSerializationState(SerializationState *state) { state->SerializationObj = TLS(SerializationObj); state->SerializationIndex = TLS(SerializationIndex); state->SerializationDispatcher = TLS(SerializationDispatcher); state->SerializationRegistry = TLS(SerializationRegistry); state->SerializationStack = TLS(SerializationStack); }
void RestoreSerializationState(SerializationState *state) { TLS(SerializationObj) = state->SerializationObj; TLS(SerializationIndex) = state->SerializationIndex; TLS(SerializationDispatcher) = state->SerializationDispatcher; TLS(SerializationRegistry) = state->SerializationRegistry; TLS(SerializationStack) = state->SerializationStack; }
static void InitNativeStringSerializer(Obj string) { TLS(SerializationStack) = NEW_PLIST(T_PLIST, 0); TLS(SerializationRegistry) = NewObjMap(); TLS(SerializationDispatcher) = &NativeStringSerializer; TLS(SerializationObj) = string; TLS(SerializationIndex) = 0; }
static void ReadBytesNativeString(void *addr, UInt size) { Obj str = TLS(SerializationObj); UInt max = GET_LEN_STRING(str); UInt off = TLS(SerializationIndex); if (off + size > max) DeserializationError(); memcpy(addr, CSTR_STRING(str)+off, size); TLS(SerializationIndex) += size; }
static UInt ReadByteBlockLengthNativeString() { UInt len; ReadBytesNativeString(&len, sizeof(len)); /* The following is to prevent out-of-memory errors on malformed input, * where incorrect values can result in huge length values: */ if (len + TLS(SerializationIndex) > GET_LEN_STRING(TLS(SerializationObj))) DeserializationError(); return len; }
int SerializedAlready(Obj obj) { Obj ref = LookupObjMap(TLS(SerializationRegistry), obj); if (ref) { WriteTNum(T_BACKREF); WriteImmediateObj(OBJ_BACKREF(INT_INTOBJ(ref))); return 1; } else { TLS(SerializationIndex)++; AddObjMap(TLS(SerializationRegistry), obj, INTOBJ_INT(TLS(SerializationIndex))); return 0; } }
static void WriteBytesNativeString(void *addr, UInt count) { Obj target = TLS(SerializationObj); UInt size = GET_LEN_STRING(target); GROW_STRING(target, size + count + 1); memcpy(CSTR_STRING(target) + size, addr, count); SET_LEN_STRING(target, size + count); }
static inline void PushObj(Obj obj) { Obj stack = TLS(SerializationStack); UInt len = LEN_PLIST(stack); len++; GROW_PLIST(stack, len); SET_LEN_PLIST(stack, len); SET_ELM_PLIST(stack, len, obj); }
static inline Obj PopObj(void) { Obj stack = TLS(SerializationStack); UInt len = LEN_PLIST(stack); Obj result = ELM_PLIST(stack, len); SET_ELM_PLIST(stack, len, (Obj) 0); len--; SET_LEN_PLIST(stack, len); return result; }
//+------------------------------------------------------------------------- // // Member: FormSetClipboard(IDataObject *pdo) // // Synopsis: helper function to set the clipboard contents // //-------------------------------------------------------------------------- HRESULT FormSetClipboard(IDataObject* pdo) { HRESULT hr; hr = OleSetClipboard(pdo); if(!hr && !GetPrimaryObjectCount()) { hr = OleFlushClipboard(); } else { TLS(pDataClip) = pdo; } RRETURN(hr); }
//+--------------------------------------------------------------------------- // // Member: CScrollbarController::StopScrollbarController // // Synopsis: Stop an existing scroll bar controller. // // Arguments: none // // Notes: // //---------------------------------------------------------------------------- void CScrollbarController::StopScrollbarController() { CScrollbarController* pSBC = TLS(pSBC); Assert(pSBC != NULL); if(pSBC->_pLayout != NULL) { // report scroll change to layout, which will take care of // invalidation pSBC->_pLayout->OnScroll(pSBC->_direction, SB_ENDSCROLL, 0); // do this before GWReleaseCapture, or StopScrollbarController // will be called recursively pSBC->_pLayout = NULL; if(pSBC->_partPressed != SBP_THUMB) { FormsKillTimer(pSBC, SB_REPEAT_TIMER); } GWReleaseCapture(pSBC); } }
static void ReserveBytesNativeString(UInt count) { Obj target = TLS(SerializationObj); UInt size = GET_LEN_STRING(target); GROW_STRING(target, size + count + 1); }
int cPlugs::PlugIN(const char * file , const char * cert , int ex) { HMODULE hModule; cPlug dll; IMLOG("* plugin - %s" , file); try { dll.priority = PLUGP_NONE; dll.Ctrl = 0; hModule = LoadLibrary(file); if (!hModule) { string err = "Load Failed ["; int errNo = GetLastError(); err +=inttoch(errNo); err +="] "; err +=GetLastErrorMsg(errNo); strcpy(TLS().buff , err.c_str()); throw (char*)TLS().buff; } dll.IMessageProc=(fIMessageProc)GetProcAddress(hModule , "IMessageProc"); if (!dll.IMessageProc) { dll.IMessageProc=(fIMessageProc)GetProcAddress(hModule , "_IMessageProc@4"); if (!dll.IMessageProc) throw "IMessageProc not found!"; } dll.file = file; dll.hModule=hModule; // if (Plug.size() < 1) { // ID dla UI jest inne od pozosta³ych // dll.ID = Plug.size(); // } else { dll.ID=(unsigned int)Plug.size()+PLUG_MAX_COUNT; // <=0x80 to identyfikatory... Do 127 wtyczek! // } /* if (cert) { char * ch = (char*)IMessageDirect(dll,IM_PLUG_CERT , 0 , 0); if (!ch || strcmp(cert , ch)) throw "Unsuplied CERT"; }*/ dll.running = true; dll.type=IMessageDirect(dll,IM_PLUG_TYPE , 0 , 0 , 0); dll.version=safeChar(IMessageDirect(dll,IM_PLUG_VERSION , 0 , 0 , 0)); if (dll.version.empty()) { FileVersionInfo(dll.file.c_str() , TLS().buff2); dll.version = TLS().buff2; } // Zamieniamy wersje tekstowa na liczbowa... Stamina::RegEx reg; if (reg.match("/(\\d*)[., ]*(\\d*)[., ]*(\\d*)[., ]*(\\d*)/" , dll.version.c_str())) dll.versionNumber = VERSION_TO_NUM(atoi(reg[1].c_str()) , atoi(reg[2].c_str()) , atoi(reg[3].c_str()) , atoi(reg[4].c_str())); else dll.versionNumber = 0; dll.sig=safeChar(IMessageDirect(dll,IM_PLUG_SIG , 0 , 0 , 0)); // dll.core_v=safeChar(IMessageDirect(dll,IM_PLUG_CORE_V , 0 , 0 , 0)); // dll.ui_v=safeChar(IMessageDirect(dll,IM_PLUG_UI_V , 0 , 0 , 0)); dll.net=IMessageDirect(dll,IM_PLUG_NET , 0 , 0); dll.name=safeChar(IMessageDirect(dll,IM_PLUG_NAME , 0 , 0 , 0)); dll.netname=safeChar(IMessageDirect(dll,IM_PLUG_NETNAME , 0 , 0 , 0)); if (IMessageDirect(dll,IM_PLUG_SDKVERSION , 0 , 0 , 0) < KONNEKT_SDK_V) throw "Wtyczka przygotowana zosta³a dla starszej wersji API. Poszukaj nowszej wersji!"; if (Plug.size() > 0 && dll.net==0) throw "Bad Net value!"; if (dll.sig=="" || dll.name=="") throw "Sig|Name required!"; // if (dll.core_v!="" && dll.core_v!=core_v) throw "incompatible Core"; // if (ui_v!="" && dll.ui_v!="" && dll.ui_v!=ui_v) throw "incompatible UserInterface"; if (Plug.size()==0) {//ui_v=dll.sig; ui_sender=dll.ID; } dll.Ctrl = ex? createCorePluginCtrl() : createPluginCtrl(); dll.Ctrl->setCtrl(dll.ID , hModule); dll.running = true; if (!IMessageDirect(dll,IM_PLUG_INIT , (tIMP)(dll.Ctrl) , (tIMP)dll.hModule , 0)) throw "IM_INIT failed"; if (ex) IMessageDirect(dll,IM_PLUG_INITEX , (tIMP)(dll.Ctrl) , 0 , 0); int pos = this->push(dll); if (dll.net == -1) { /* odpytujemy raz jeszcze, sam nas o to prosi³... */ Plug[pos].net =IMessageDirect(dll,IM_PLUG_NET , 0 , 0); Plug[pos].name=safeChar(IMessageDirect(dll,IM_PLUG_NAME , 0 , 0 , 0)); Plug[pos].netname=safeChar(IMessageDirect(dll,IM_PLUG_NETNAME , 0 , 0 , 0)); if (Plug[pos].name=="") throw "Sig|Name required!"; } // Wtyczka zostala zatwierdzona i dodana // cPlug & plg = Plug[Plug.size()-1]; } catch (char * er) { if (dll.Ctrl) {delete dll.Ctrl;dll.Ctrl = 0;} if (hModule) FreeLibrary(hModule); CStdString errMsg; errMsg.Format(resString(IDS_ERR_DLL).c_str() , file , er); int ret = MessageBox(NULL , errMsg , resStr(IDS_APPNAME) , MB_ICONWARNING|MB_YESNOCANCEL|MB_TASKMODAL); if (ret == IDCANCEL) abort(); return ret == IDYES? 0 : -1; } return 1; }
/* 'InitLibrary' sets up gvars, rnams, functions */ static Int InitLibrary ( StructInitInfo * module ) { Obj func1; Obj body1; /* Complete Copy/Fopy registration */ UpdateCopyFopyInfo(); /* global variables used in handlers */ G_IS__FUNCTION = GVarName( "IS_FUNCTION" ); G_ADD__LIST = GVarName( "ADD_LIST" ); G_Error = GVarName( "Error" ); G_IS__IDENTICAL__OBJ = GVarName( "IS_IDENTICAL_OBJ" ); G_AND__FLAGS = GVarName( "AND_FLAGS" ); G_HASH__FLAGS = GVarName( "HASH_FLAGS" ); G_WITH__HIDDEN__IMPS__FLAGS = GVarName( "WITH_HIDDEN_IMPS_FLAGS" ); G_IS__SUBSET__FLAGS = GVarName( "IS_SUBSET_FLAGS" ); G_TRUES__FLAGS = GVarName( "TRUES_FLAGS" ); G_FLAGS__FILTER = GVarName( "FLAGS_FILTER" ); G_WITH__HIDDEN__IMPS__FLAGS__COUNT = GVarName( "WITH_HIDDEN_IMPS_FLAGS_COUNT" ); G_WITH__HIDDEN__IMPS__FLAGS__CACHE__MISS = GVarName( "WITH_HIDDEN_IMPS_FLAGS_CACHE_MISS" ); G_WITH__HIDDEN__IMPS__FLAGS__CACHE__HIT = GVarName( "WITH_HIDDEN_IMPS_FLAGS_CACHE_HIT" ); G_IMPLICATIONS = GVarName( "IMPLICATIONS" ); G_WITH__IMPS__FLAGS__CACHE = GVarName( "WITH_IMPS_FLAGS_CACHE" ); G_WITH__IMPS__FLAGS__COUNT = GVarName( "WITH_IMPS_FLAGS_COUNT" ); G_WITH__IMPS__FLAGS__CACHE__HIT = GVarName( "WITH_IMPS_FLAGS_CACHE_HIT" ); G_WITH__IMPS__FLAGS__CACHE__MISS = GVarName( "WITH_IMPS_FLAGS_CACHE_MISS" ); G_CLEAR__IMP__CACHE = GVarName( "CLEAR_IMP_CACHE" ); G_BIND__GLOBAL = GVarName( "BIND_GLOBAL" ); G_UNBIND__GLOBAL = GVarName( "UNBIND_GLOBAL" ); G_RANK__FILTERS = GVarName( "RANK_FILTERS" ); G_RankFilter = GVarName( "RankFilter" ); G_RANK__FILTER = GVarName( "RANK_FILTER" ); G_RANK__FILTER__LIST__CURRENT = GVarName( "RANK_FILTER_LIST_CURRENT" ); G_RANK__FILTER__LIST = GVarName( "RANK_FILTER_LIST" ); G_RANK__FILTER__COUNT = GVarName( "RANK_FILTER_COUNT" ); /* record names used in handlers */ /* information for the functions */ C_NEW_STRING( DefaultName, 14, "local function" ); C_NEW_STRING( FileName, 21, "GAPROOT/lib/filter1.g" ); NameFunc[1] = DefaultName; NamsFunc[1] = 0; NargFunc[1] = 0; NameFunc[2] = DefaultName; NamsFunc[2] = 0; NargFunc[2] = 0; NameFunc[3] = DefaultName; NamsFunc[3] = 0; NargFunc[3] = 1; NameFunc[4] = DefaultName; NamsFunc[4] = 0; NargFunc[4] = 1; NameFunc[5] = DefaultName; NamsFunc[5] = 0; NargFunc[5] = 1; NameFunc[6] = DefaultName; NamsFunc[6] = 0; NargFunc[6] = 1; /* create all the functions defined in this module */ func1 = NewFunction(NameFunc[1],NargFunc[1],NamsFunc[1],HdlrFunc1); ENVI_FUNC( func1 ) = TLS(CurrLVars); CHANGED_BAG( TLS(CurrLVars) ); body1 = NewBag( T_BODY, NUMBER_HEADER_ITEMS_BODY*sizeof(Obj)); BODY_FUNC( func1 ) = body1; CHANGED_BAG( func1 ); CALL_0ARGS( func1 ); /* return success */ return 0; }
/* handler for function 1 */ static Obj HdlrFunc1 ( Obj self ) { Obj t_1 = 0; Obj t_2 = 0; Obj t_3 = 0; Obj t_4 = 0; Bag oldFrame; OLD_BRK_CURR_STAT /* allocate new stack frame */ SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); REM_BRK_CURR_STAT(); SET_BRK_CURR_STAT(0); /* WITH_HIDDEN_IMPS_FLAGS_COUNT := 0; */ AssGVar( G_WITH__HIDDEN__IMPS__FLAGS__COUNT, INTOBJ_INT(0) ); /* WITH_HIDDEN_IMPS_FLAGS_CACHE_MISS := 0; */ AssGVar( G_WITH__HIDDEN__IMPS__FLAGS__CACHE__MISS, INTOBJ_INT(0) ); /* WITH_HIDDEN_IMPS_FLAGS_CACHE_HIT := 0; */ AssGVar( G_WITH__HIDDEN__IMPS__FLAGS__CACHE__HIT, INTOBJ_INT(0) ); /* IMPLICATIONS := [ ]; */ t_1 = NEW_PLIST( T_PLIST, 0 ); SET_LEN_PLIST( t_1, 0 ); AssGVar( G_IMPLICATIONS, t_1 ); /* WITH_IMPS_FLAGS_CACHE := [ ]; */ t_1 = NEW_PLIST( T_PLIST, 0 ); SET_LEN_PLIST( t_1, 0 ); AssGVar( G_WITH__IMPS__FLAGS__CACHE, t_1 ); /* WITH_IMPS_FLAGS_COUNT := 0; */ AssGVar( G_WITH__IMPS__FLAGS__COUNT, INTOBJ_INT(0) ); /* WITH_IMPS_FLAGS_CACHE_HIT := 0; */ AssGVar( G_WITH__IMPS__FLAGS__CACHE__HIT, INTOBJ_INT(0) ); /* WITH_IMPS_FLAGS_CACHE_MISS := 0; */ AssGVar( G_WITH__IMPS__FLAGS__CACHE__MISS, INTOBJ_INT(0) ); /* Unbind( CLEAR_IMP_CACHE ); */ AssGVar( G_CLEAR__IMP__CACHE, 0 ); /* BIND_GLOBAL( "CLEAR_IMP_CACHE", function ( ) WITH_IMPS_FLAGS_CACHE := [ ]; return; end ); */ t_1 = GF_BIND__GLOBAL; C_NEW_STRING( t_2, 15, "CLEAR_IMP_CACHE" ); t_3 = NewFunction( NameFunc[2], NargFunc[2], NamsFunc[2], HdlrFunc2 ); ENVI_FUNC( t_3 ) = TLS(CurrLVars); t_4 = NewBag( T_BODY, NUMBER_HEADER_ITEMS_BODY*sizeof(Obj) ); STARTLINE_BODY(t_4) = INTOBJ_INT(39); ENDLINE_BODY(t_4) = INTOBJ_INT(41); FILENAME_BODY(t_4) = FileName; BODY_FUNC(t_3) = t_4; CHANGED_BAG( TLS(CurrLVars) ); CALL_2ARGS( t_1, t_2, t_3 ); /* BIND_GLOBAL( "WITH_IMPS_FLAGS", function ( flags ) local with, changed, imp, hash, hash2, i; hash := HASH_FLAGS( flags ) mod 11001; for i in [ 0 .. 3 ] do hash2 := 2 * ((hash + 31 * i) mod 11001) + 1; if IsBound( WITH_IMPS_FLAGS_CACHE[hash2] ) then if IS_IDENTICAL_OBJ( WITH_IMPS_FLAGS_CACHE[hash2], flags ) then WITH_IMPS_FLAGS_CACHE_HIT := WITH_IMPS_FLAGS_CACHE_HIT + 1; return WITH_IMPS_FLAGS_CACHE[hash2 + 1]; fi; else break; fi; od; if i = 3 then WITH_IMPS_FLAGS_COUNT := (WITH_IMPS_FLAGS_COUNT + 1) mod 4; i := WITH_IMPS_FLAGS_COUNT; hash2 := 2 * ((hash + 31 * i) mod 11001) + 1; fi; WITH_IMPS_FLAGS_CACHE_MISS := WITH_IMPS_FLAGS_CACHE_MISS + 1; with := flags; changed := true; while changed do changed := false; for imp in IMPLICATIONS do if IS_SUBSET_FLAGS( with, imp[2] ) and not IS_SUBSET_FLAGS( with, imp[1] ) then with := AND_FLAGS( with, imp[1] ); changed := true; fi; od; od; WITH_IMPS_FLAGS_CACHE[hash2] := flags; WITH_IMPS_FLAGS_CACHE[hash2 + 1] := with; return with; end ); */ t_1 = GF_BIND__GLOBAL; C_NEW_STRING( t_2, 15, "WITH_IMPS_FLAGS" ); t_3 = NewFunction( NameFunc[3], NargFunc[3], NamsFunc[3], HdlrFunc3 ); ENVI_FUNC( t_3 ) = TLS(CurrLVars); t_4 = NewBag( T_BODY, NUMBER_HEADER_ITEMS_BODY*sizeof(Obj) ); STARTLINE_BODY(t_4) = INTOBJ_INT(44); ENDLINE_BODY(t_4) = INTOBJ_INT(83); FILENAME_BODY(t_4) = FileName; BODY_FUNC(t_3) = t_4; CHANGED_BAG( TLS(CurrLVars) ); CALL_2ARGS( t_1, t_2, t_3 ); /* UNBIND_GLOBAL( "RANK_FILTER" ); */ t_1 = GF_UNBIND__GLOBAL; C_NEW_STRING( t_2, 11, "RANK_FILTER" ); CALL_1ARGS( t_1, t_2 ); /* BIND_GLOBAL( "RANK_FILTER", function ( filter ) local rank, flags, i; rank := 0; if IS_FUNCTION( filter ) then flags := FLAGS_FILTER( filter ); else flags := filter; fi; for i in TRUES_FLAGS( WITH_HIDDEN_IMPS_FLAGS( flags ) ) do if IsBound( RANK_FILTERS[i] ) then rank := rank + RANK_FILTERS[i]; else rank := rank + 1; fi; od; return rank; end ); */ t_1 = GF_BIND__GLOBAL; C_NEW_STRING( t_2, 11, "RANK_FILTER" ); t_3 = NewFunction( NameFunc[4], NargFunc[4], NamsFunc[4], HdlrFunc4 ); ENVI_FUNC( t_3 ) = TLS(CurrLVars); t_4 = NewBag( T_BODY, NUMBER_HEADER_ITEMS_BODY*sizeof(Obj) ); STARTLINE_BODY(t_4) = INTOBJ_INT(97); ENDLINE_BODY(t_4) = INTOBJ_INT(114); FILENAME_BODY(t_4) = FileName; BODY_FUNC(t_3) = t_4; CHANGED_BAG( TLS(CurrLVars) ); CALL_2ARGS( t_1, t_2, t_3 ); /* RankFilter := RANK_FILTER; */ t_1 = GC_RANK__FILTER; CHECK_BOUND( t_1, "RANK_FILTER" ) AssGVar( G_RankFilter, t_1 ); /* UNBIND_GLOBAL( "RANK_FILTER_STORE" ); */ t_1 = GF_UNBIND__GLOBAL; C_NEW_STRING( t_2, 17, "RANK_FILTER_STORE" ); CALL_1ARGS( t_1, t_2 ); /* BIND_GLOBAL( "RANK_FILTER_STORE", function ( filter ) local hash, rank, flags; if IS_FUNCTION( filter ) then flags := FLAGS_FILTER( filter ); else flags := filter; fi; hash := HASH_FLAGS( flags ); rank := RANK_FILTER( flags ); ADD_LIST( RANK_FILTER_LIST_CURRENT, hash ); ADD_LIST( RANK_FILTER_LIST_CURRENT, rank ); return rank; end ); */ t_1 = GF_BIND__GLOBAL; C_NEW_STRING( t_2, 17, "RANK_FILTER_STORE" ); t_3 = NewFunction( NameFunc[5], NargFunc[5], NamsFunc[5], HdlrFunc5 ); ENVI_FUNC( t_3 ) = TLS(CurrLVars); t_4 = NewBag( T_BODY, NUMBER_HEADER_ITEMS_BODY*sizeof(Obj) ); STARTLINE_BODY(t_4) = INTOBJ_INT(119); ENDLINE_BODY(t_4) = INTOBJ_INT(133); FILENAME_BODY(t_4) = FileName; BODY_FUNC(t_3) = t_4; CHANGED_BAG( TLS(CurrLVars) ); CALL_2ARGS( t_1, t_2, t_3 ); /* UNBIND_GLOBAL( "RANK_FILTER_COMPLETION" ); */ t_1 = GF_UNBIND__GLOBAL; C_NEW_STRING( t_2, 22, "RANK_FILTER_COMPLETION" ); CALL_1ARGS( t_1, t_2 ); /* BIND_GLOBAL( "RANK_FILTER_COMPLETION", function ( filter ) local hash, flags; if IS_FUNCTION( filter ) then flags := FLAGS_FILTER( filter ); else flags := filter; fi; hash := HASH_FLAGS( flags ); if hash <> RANK_FILTER_LIST[RANK_FILTER_COUNT] then Error( "corrupted completion file" ); fi; RANK_FILTER_COUNT := RANK_FILTER_COUNT + 2; return RANK_FILTER_LIST[RANK_FILTER_COUNT - 1]; end ); */ t_1 = GF_BIND__GLOBAL; C_NEW_STRING( t_2, 22, "RANK_FILTER_COMPLETION" ); t_3 = NewFunction( NameFunc[6], NargFunc[6], NamsFunc[6], HdlrFunc6 ); ENVI_FUNC( t_3 ) = TLS(CurrLVars); t_4 = NewBag( T_BODY, NUMBER_HEADER_ITEMS_BODY*sizeof(Obj) ); STARTLINE_BODY(t_4) = INTOBJ_INT(136); ENDLINE_BODY(t_4) = INTOBJ_INT(151); FILENAME_BODY(t_4) = FileName; BODY_FUNC(t_3) = t_4; CHANGED_BAG( TLS(CurrLVars) ); CALL_2ARGS( t_1, t_2, t_3 ); /* return; */ RES_BRK_CURR_STAT(); SWITCH_TO_OLD_FRAME(oldFrame); return 0; /* return; */ RES_BRK_CURR_STAT(); SWITCH_TO_OLD_FRAME(oldFrame); return 0; }
//+--------------------------------------------------------------------------- // // Member: CScrollbarController::StartScrollbarController // // Synopsis: Start a scroll bar controller if necessary. // // Arguments: pLayout layout object to be called on scroll changes // pDispScroller display scroller node // pServerHost server host // buttonWidth custom scroll bar button width // pMessage message that caused creation of controller // // Notes: // //---------------------------------------------------------------------------- void CScrollbarController::StartScrollbarController( CLayout* pLayout, CDispScroller* pDispScroller, CServer* pServerHost, long buttonWidth, CMessage* pMessage) { Assert(pLayout != NULL); Assert(pDispScroller != NULL); Assert(pServerHost != NULL); Assert(pMessage != NULL); BOOL fRightToLeft; CScrollbarController* pSBC = TLS(pSBC); Assert(pSBC != NULL); // just to make sure previous controller is stopped if(pSBC->_pLayout != NULL) { StopScrollbarController(); } pSBC->_direction = (pMessage->htc==HTC_HSCROLLBAR ? 0 : 1); pSBC->_pDispScroller = pDispScroller; pSBC->_drawInfo.Init(pLayout->ElementOwner()); fRightToLeft = (pSBC->_direction==0 && pDispScroller->IsRightToLeft()); // calculate scroll bar rect pDispScroller->GetClientRect( &pSBC->_rcScrollbar, (pSBC->_direction==0?CLIENTRECT_HSCROLLBAR:CLIENTRECT_VSCROLLBAR)); Assert(pSBC->_rcScrollbar.Contains(pMessage->ptContent)); LONG contentSize, containerSize, scrollAmount; pSBC->GetScrollInfo(&contentSize, &containerSize, &scrollAmount); // if the scrollbar is inactive, it doesn't matter what was pressed if(contentSize <= containerSize) { return; } // what was pressed? pSBC->_partPressed = GetPart( pSBC->_direction, pSBC->_rcScrollbar, pMessage->ptContent, contentSize, containerSize, scrollAmount, buttonWidth, pSBC->GetDrawInfo(), pDispScroller->IsRightToLeft()); Assert(pSBC->_partPressed != SBP_NONE); // if inactive track was pressed, no more work to do if(pSBC->_partPressed == SBP_TRACK) { return; } // make scroll bar controller active pSBC->_partPressedStart = pSBC->_partPressed; pSBC->_pLayout = pLayout; pSBC->_pDispScroller = pDispScroller; pSBC->_pServerHost = pServerHost; pSBC->_buttonWidth = buttonWidth; pSBC->_ptMouse = pMessage->ptContent; LONG lScrollTime = MAX_SCROLLTIME; // if thumbing, compute hit point offset from top of thumb if(pSBC->_partPressed == SBP_THUMB) { long trackSize = GetTrackSize( pSBC->_direction, pSBC->_rcScrollbar, pSBC->_buttonWidth); long thumbSize = GetThumbSize( pSBC->_direction, pSBC->_rcScrollbar, contentSize, containerSize, pSBC->_buttonWidth, pSBC->GetDrawInfo()); // _mouseInThumb is the xPos of the mouse in from the left edge of the thumb in LTR cases // and xPos of the mouse in from the right edge of the thumb in RTL HSCROLL cases if(!fRightToLeft) { pSBC->_mouseInThumb = pSBC->_ptMouse[pSBC->_direction] - pSBC->_rcScrollbar[pSBC->_direction] - GetScaledButtonWidth(pSBC->_direction, pSBC->_rcScrollbar, pSBC->_buttonWidth) - GetThumbOffset(contentSize, containerSize, scrollAmount, trackSize, thumbSize); } else { pSBC->_mouseInThumb = pSBC->_rcScrollbar.right - GetScaledButtonWidth(pSBC->_direction, pSBC->_rcScrollbar, pSBC->_buttonWidth) + GetThumbOffset(contentSize, containerSize, scrollAmount, trackSize, thumbSize) - pSBC->_ptMouse.x; } Assert(pSBC->_mouseInThumb >= 0); // no smooth scrolling lScrollTime = 0; } // capture the mouse HWND hwnd = pServerHost->_pInPlace->_hwnd; if(FAILED(GWSetCapture( pSBC, ONMESSAGE_METHOD(CScrollbarController, OnMessage, onmessage), hwnd))) { pSBC->_pLayout = NULL; return; } // set timer for repeating actions if(pSBC->_partPressed != SBP_THUMB) { // perform first action pLayout->OnScroll( pSBC->_direction, TranslateSBAction(pSBC->_partPressed), 0, FALSE, lScrollTime); CSize scrollOffset; pSBC->_pDispScroller->GetScrollOffset(&scrollOffset); scrollAmount = scrollOffset[pSBC->_direction]; // set timer for subsequent action FormsSetTimer( pSBC, ONTICK_METHOD(CScrollbarController, OnTick, ontick), SB_REPEAT_TIMER, GetRepeatDelay()); } // invalidate the part we hit, if necessary pLayout->OpenView(); InvalidatePart( pSBC->_partPressed, pSBC->_direction, pSBC->_rcScrollbar, contentSize, containerSize, scrollAmount, buttonWidth, pDispScroller, pSBC->GetDrawInfo()); }
int get(sMRU * mru) { if (!mru || !mru->name || !mru->name[0] || !mru->count /*|| !mru->buffSize || !mru->values || !mru->values[0]*/) return 0; if (mru->flags & MRU_GET_USETEMP) mru->flags |= MRU_GET_ONEBUFF; char * temp = mru->flags&MRU_GET_USETEMP?TLS().buff : mru->buffer; size_t tempSize = mru->flags&MRU_GET_USETEMP?MAX_STRING : mru->buffSize; if (!temp || tempSize < (size_t)(4*mru->count + mru->count)) return 0; if (mru->flags & MRU_GET_ONEBUFF) { // Musimy wstawiæ puste wskaŸniki do bufora. mru->values = (char**)temp; memset(temp , 0 , 4*mru->count); temp += 4*mru->count; tempSize -= 4*mru->count; mru->values[0] = temp; } else { tempSize = mru->buffSize; } CdtFileBin FBin; CdTable TMru; TMru.cols = MRU::descriptor; TMru.cxor_key = XOR_KEY; FBin.assign(&TMru); FBin.load((profileDir + FILE_MRU).c_str()); int row = TMru.findby((TdEntry)mru->name , MRU_ID); // Zerujemy wszystkie bufory. int i = 0; while (i<mru->count && mru->values[i]) { mru->values[i][0] = 0; i++; } if (row == -1) return 0; // Udalo sie znalezc NIC, ale udalo :] string entry = (char*)TMru.get(row , MRU_VALUE); if (entry.empty()) return 0; if (*(entry.end()-1) == MRU_SEPCHAR) entry.erase(entry.end()-1); size_t current = 0; size_t next = 0; i = 0; int j = 0; // Prawdziwych while (current != -1 && mru->values[j] && i<mru->count && tempSize) { next = entry.find(MRU_SEPCHAR , current); strncpy(mru->values[j] , entry.substr(current , next==-1?-1:next-current).c_str() , tempSize); mru->values[j][tempSize-1] = 0; if (*mru->values[j]) { j++; if (mru->flags & MRU_GET_ONEBUFF) { size_t len = strlen(mru->values[j-1]); tempSize -= len+1 <= tempSize ? len+1 : tempSize; if (tempSize) temp += len+1; else temp = 0; if (j < mru->count) mru->values[j] = temp; } } current = next==-1?-1:next+1; i++; } return j; }
int CALLBACK PassDialogProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam) { sDIALOG_access * dlg; static char str_buff2 [MAX_STRBUFF]; bool login; switch (message) { case WM_INITDIALOG: SetWindowPos(hwnd , HWND_TOP , 0 , 0 , 0 , 0 , SWP_NOMOVE | SWP_NOSIZE); SetProp(hwnd , "DLG" , (void*)lParam); dlg = (sDIALOG_access*)lParam; SetWindowText(hwnd , dlg->title); SetDlgItemText(hwnd , IDC_STATIC , dlg->info); login = GetDlgItem(hwnd , IDC_LOGIN)!=0; if (login) { SetDlgItemText(hwnd , IDC_LOGIN , dlg->login); } SetDlgItemText(hwnd , IDC_PASS1 , dlg->pass); SetFocus(GetDlgItem(hwnd , login?IDC_LOGIN:IDC_PASS1)); ShowWindow(GetDlgItem(hwnd , IDC_PASS2) , dlg->flag & DFLAG_PASS2 ? SW_SHOW : SW_HIDE); // SetDlgItemText(hwnd , IDC_STATIC , dlg->info); CheckDlgButton(hwnd , IDC_CHECK , dlg->save?BST_CHECKED:BST_UNCHECKED); ShowWindow(GetDlgItem(hwnd , IDC_CHECK) , dlg->flag & DFLAG_SAVE ? SW_SHOW : SW_HIDE); break; case WM_CLOSE: EndDialog(hwnd, IDCANCEL); break; case WM_NCDESTROY: dlg=(sDIALOG_access*)GetProp(hwnd , "DLG"); RemoveProp(hwnd , "DLG"); break; case WM_COMMAND: dlg=(sDIALOG_access*)GetProp(hwnd , "DLG"); switch (LOWORD(wParam)) { case IDOK: login = GetDlgItem(hwnd , IDC_LOGIN)!=0; GetDlgItemText(hwnd , IDC_PASS1 , TLS().buff , MAX_STRING); if (login) { GetDlgItemText(hwnd , IDC_LOGIN , TLS().buff2 , MAX_STRING); dlg->login = TLS().buff2; } if (GetDlgItem(hwnd , IDC_PASS2) && IsWindowVisible(GetDlgItem(hwnd , IDC_PASS2))) { GetDlgItemText(hwnd , IDC_PASS2 , TLS().str.GetBuffer(MAX_STRBUFF) , MAX_STRBUFF); TLS().str.ReleaseBuffer(); if (TLS().str != TLS().buff) { IMessage(IMI_WARNING , 0 , 0 , (int)"Zrobi³eœ b³¹d przy potwierdzaniu has³a! \nWpisz w oba pola TO SAMO has³o!"); break; } } dlg->pass = TLS().buff; dlg->save = IsDlgButtonChecked(hwnd , IDC_CHECK)==BST_CHECKED; // Fall through. case IDCANCEL: EndDialog(hwnd, wParam); return TRUE; } } return 0; }