| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667 |
- // This is a part of the Microsoft Foundation Classes C++ library.
- // Copyright (C) 1992-1998 Microsoft Corporation
- // All rights reserved.
- //
- // This source code is only intended as a supplement to the
- // Microsoft Foundation Classes Reference and related
- // electronic documentation provided with the library.
- // See these sources for detailed information regarding the
- // Microsoft Foundation Classes product.
- #ifndef __AFXWIN_H__
- #ifndef RC_INVOKED
- #define __AFXWIN_H__
- /////////////////////////////////////////////////////////////////////////////
- // Make sure 'afx.h' is included first
- #ifndef __AFX_H__
- #include <afx.h>
- #endif
- // Note: WINDOWS.H already included from AFXV_W32.H
- #ifndef _INC_SHELLAPI
- #include <shellapi.h>
- #endif
- #ifndef __AFXRES_H__
- #include <afxres.h> // standard resource IDs
- #endif
- #ifndef __AFXCOLL_H__
- #include <afxcoll.h> // standard collections
- #endif
- #ifdef _AFX_MINREBUILD
- #pragma component(minrebuild, off)
- #endif
- #ifndef _AFX_FULLTYPEINFO
- #pragma component(mintypeinfo, on)
- #endif
- #ifndef _AFX_NOFORCE_LIBS
- #pragma comment(lib, "uuid.lib")
- #endif
- #ifdef _INC_WINDOWSX
- // The following names from WINDOWSX.H collide with names in this header
- #undef SubclassWindow
- #undef CopyRgn
- #endif
- #ifdef _AFX_PACKING
- #pragma pack(push, _AFX_PACKING)
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // Classes declared in this file
- class CSize;
- class CPoint;
- class CRect;
- //CObject
- //CException
- //CSimpleException
- class CResourceException;// Win resource failure exception
- class CUserException; // Message Box alert and stop operation
- class CGdiObject; // CDC drawing tool
- class CPen; // a pen / HPEN wrapper
- class CBrush; // a brush / HBRUSH wrapper
- class CFont; // a font / HFONT wrapper
- class CBitmap; // a bitmap / HBITMAP wrapper
- class CPalette; // a palette / HPALLETE wrapper
- class CRgn; // a region / HRGN wrapper
- class CDC; // a Display Context / HDC wrapper
- class CClientDC; // CDC for client of window
- class CWindowDC; // CDC for entire window
- class CPaintDC; // embeddable BeginPaint struct helper
- class CMenu; // a menu / HMENU wrapper
- class CCmdTarget; // a target for user commands
- class CWnd; // a window / HWND wrapper
- class CDialog; // a dialog
- // standard windows controls
- class CStatic; // Static control
- class CButton; // Button control
- class CListBox; // ListBox control
- class CCheckListBox;// special listbox with checks
- class CComboBox; // ComboBox control
- class CEdit; // Edit control
- class CScrollBar; // ScrollBar control
- // frame windows
- class CFrameWnd; // standard SDI frame
- class CMDIFrameWnd; // standard MDI frame
- class CMDIChildWnd; // standard MDI child
- class CMiniFrameWnd;// half-height caption frame wnd
- // views on a document
- class CView; // a view on a document
- class CScrollView; // a scrolling view
- class CWinThread; // thread base class
- class CWinApp; // application base class
- class CDocTemplate; // template for document creation
- class CSingleDocTemplate;// SDI support
- class CMultiDocTemplate; // MDI support
- class CDocument; // main document abstraction
- // Helper classes
- class CCmdUI; // Menu/button enabling
- class CDataExchange; // Data exchange and validation context
- class CCommandLineInfo; // CommandLine parsing helper
- class CDocManager; // CDocTemplate manager object
- /////////////////////////////////////////////////////////////////////////////
- // Type modifier for message handlers
- #ifndef afx_msg
- #define afx_msg // intentional placeholder
- #endif
- #undef AFX_DATA
- #define AFX_DATA AFX_CORE_DATA
- /////////////////////////////////////////////////////////////////////////////
- // CSize - An extent, similar to Windows SIZE structure.
- class CSize : public tagSIZE
- {
- public:
- // Constructors
- // construct an uninitialized size
- CSize();
- // create from two integers
- CSize(int initCX, int initCY);
- // create from another size
- CSize(SIZE initSize);
- // create from a point
- CSize(POINT initPt);
- // create from a DWORD: cx = LOWORD(dw) cy = HIWORD(dw)
- CSize(DWORD dwSize);
- // Operations
- BOOL operator==(SIZE size) const;
- BOOL operator!=(SIZE size) const;
- void operator+=(SIZE size);
- void operator-=(SIZE size);
- // Operators returning CSize values
- CSize operator+(SIZE size) const;
- CSize operator-(SIZE size) const;
- CSize operator-() const;
- // Operators returning CPoint values
- CPoint operator+(POINT point) const;
- CPoint operator-(POINT point) const;
- // Operators returning CRect values
- CRect operator+(const RECT* lpRect) const;
- CRect operator-(const RECT* lpRect) const;
- };
- /////////////////////////////////////////////////////////////////////////////
- // CPoint - A 2-D point, similar to Windows POINT structure.
- class CPoint : public tagPOINT
- {
- public:
- // Constructors
- // create an uninitialized point
- CPoint();
- // create from two integers
- CPoint(int initX, int initY);
- // create from another point
- CPoint(POINT initPt);
- // create from a size
- CPoint(SIZE initSize);
- // create from a dword: x = LOWORD(dw) y = HIWORD(dw)
- CPoint(DWORD dwPoint);
- // Operations
- // translate the point
- void Offset(int xOffset, int yOffset);
- void Offset(POINT point);
- void Offset(SIZE size);
- BOOL operator==(POINT point) const;
- BOOL operator!=(POINT point) const;
- void operator+=(SIZE size);
- void operator-=(SIZE size);
- void operator+=(POINT point);
- void operator-=(POINT point);
- // Operators returning CPoint values
- CPoint operator+(SIZE size) const;
- CPoint operator-(SIZE size) const;
- CPoint operator-() const;
- CPoint operator+(POINT point) const;
- // Operators returning CSize values
- CSize operator-(POINT point) const;
- // Operators returning CRect values
- CRect operator+(const RECT* lpRect) const;
- CRect operator-(const RECT* lpRect) const;
- };
- /////////////////////////////////////////////////////////////////////////////
- // CRect - A 2-D rectangle, similar to Windows RECT structure.
- typedef const RECT* LPCRECT; // pointer to read/only RECT
- class CRect : public tagRECT
- {
- public:
- // Constructors
- // uninitialized rectangle
- CRect();
- // from left, top, right, and bottom
- CRect(int l, int t, int r, int b);
- // copy constructor
- CRect(const RECT& srcRect);
- // from a pointer to another rect
- CRect(LPCRECT lpSrcRect);
- // from a point and size
- CRect(POINT point, SIZE size);
- // from two points
- CRect(POINT topLeft, POINT bottomRight);
- // Attributes (in addition to RECT members)
- // retrieves the width
- int Width() const;
- // returns the height
- int Height() const;
- // returns the size
- CSize Size() const;
- // reference to the top-left point
- CPoint& TopLeft();
- // reference to the bottom-right point
- CPoint& BottomRight();
- // const reference to the top-left point
- const CPoint& TopLeft() const;
- // const reference to the bottom-right point
- const CPoint& BottomRight() const;
- // the geometric center point of the rectangle
- CPoint CenterPoint() const;
- // swap the left and right
- void SwapLeftRight();
- static void SwapLeftRight(LPRECT lpRect);
- // convert between CRect and LPRECT/LPCRECT (no need for &)
- operator LPRECT();
- operator LPCRECT() const;
- // returns TRUE if rectangle has no area
- BOOL IsRectEmpty() const;
- // returns TRUE if rectangle is at (0,0) and has no area
- BOOL IsRectNull() const;
- // returns TRUE if point is within rectangle
- BOOL PtInRect(POINT point) const;
- // Operations
- // set rectangle from left, top, right, and bottom
- void SetRect(int x1, int y1, int x2, int y2);
- void SetRect(POINT topLeft, POINT bottomRight);
- // empty the rectangle
- void SetRectEmpty();
- // copy from another rectangle
- void CopyRect(LPCRECT lpSrcRect);
- // TRUE if exactly the same as another rectangle
- BOOL EqualRect(LPCRECT lpRect) const;
- // inflate rectangle's width and height without
- // moving its top or left
- void InflateRect(int x, int y);
- void InflateRect(SIZE size);
- void InflateRect(LPCRECT lpRect);
- void InflateRect(int l, int t, int r, int b);
- // deflate the rectangle's width and height without
- // moving its top or left
- void DeflateRect(int x, int y);
- void DeflateRect(SIZE size);
- void DeflateRect(LPCRECT lpRect);
- void DeflateRect(int l, int t, int r, int b);
- // translate the rectangle by moving its top and left
- void OffsetRect(int x, int y);
- void OffsetRect(SIZE size);
- void OffsetRect(POINT point);
- void NormalizeRect();
- // set this rectangle to intersection of two others
- BOOL IntersectRect(LPCRECT lpRect1, LPCRECT lpRect2);
- // set this rectangle to bounding union of two others
- BOOL UnionRect(LPCRECT lpRect1, LPCRECT lpRect2);
- // set this rectangle to minimum of two others
- BOOL SubtractRect(LPCRECT lpRectSrc1, LPCRECT lpRectSrc2);
- // Additional Operations
- void operator=(const RECT& srcRect);
- BOOL operator==(const RECT& rect) const;
- BOOL operator!=(const RECT& rect) const;
- void operator+=(POINT point);
- void operator+=(SIZE size);
- void operator+=(LPCRECT lpRect);
- void operator-=(POINT point);
- void operator-=(SIZE size);
- void operator-=(LPCRECT lpRect);
- void operator&=(const RECT& rect);
- void operator|=(const RECT& rect);
- // Operators returning CRect values
- CRect operator+(POINT point) const;
- CRect operator-(POINT point) const;
- CRect operator+(LPCRECT lpRect) const;
- CRect operator+(SIZE size) const;
- CRect operator-(SIZE size) const;
- CRect operator-(LPCRECT lpRect) const;
- CRect operator&(const RECT& rect2) const;
- CRect operator|(const RECT& rect2) const;
- CRect MulDiv(int nMultiplier, int nDivisor) const;
- };
- #ifdef _DEBUG
- // Diagnostic Output
- CDumpContext& AFXAPI operator<<(CDumpContext& dc, SIZE size);
- CDumpContext& AFXAPI operator<<(CDumpContext& dc, POINT point);
- CDumpContext& AFXAPI operator<<(CDumpContext& dc, const RECT& rect);
- #endif //_DEBUG
- // Serialization
- CArchive& AFXAPI operator<<(CArchive& ar, SIZE size);
- CArchive& AFXAPI operator<<(CArchive& ar, POINT point);
- CArchive& AFXAPI operator<<(CArchive& ar, const RECT& rect);
- CArchive& AFXAPI operator>>(CArchive& ar, SIZE& size);
- CArchive& AFXAPI operator>>(CArchive& ar, POINT& point);
- CArchive& AFXAPI operator>>(CArchive& ar, RECT& rect);
- /////////////////////////////////////////////////////////////////////////////
- // Standard exceptions
- class CResourceException : public CSimpleException // resource failure
- {
- DECLARE_DYNAMIC(CResourceException)
- public:
- CResourceException();
- // Implementation
- public:
- CResourceException(BOOL bAutoDelete);
- CResourceException(BOOL bAutoDelete, UINT nResourceID);
- virtual ~CResourceException();
- };
- class CUserException : public CSimpleException // general user visible alert
- {
- DECLARE_DYNAMIC(CUserException)
- public:
- CUserException();
- // Implementation
- public:
- CUserException(BOOL bAutoDelete);
- CUserException(BOOL bAutoDelete, UINT nResourceID);
- virtual ~CUserException();
- };
- void AFXAPI AfxThrowResourceException();
- void AFXAPI AfxThrowUserException();
- /////////////////////////////////////////////////////////////////////////////
- // CGdiObject abstract class for CDC SelectObject
- class CGdiObject : public CObject
- {
- DECLARE_DYNCREATE(CGdiObject)
- public:
- // Attributes
- HGDIOBJ m_hObject; // must be first data member
- operator HGDIOBJ() const;
- HGDIOBJ GetSafeHandle() const;
- static CGdiObject* PASCAL FromHandle(HGDIOBJ hObject);
- static void PASCAL DeleteTempMap();
- BOOL Attach(HGDIOBJ hObject);
- HGDIOBJ Detach();
- // Constructors
- CGdiObject(); // must Create a derived class object
- BOOL DeleteObject();
- // Operations
- int GetObject(int nCount, LPVOID lpObject) const;
- UINT GetObjectType() const;
- BOOL CreateStockObject(int nIndex);
- BOOL UnrealizeObject();
- BOOL operator==(const CGdiObject& obj) const;
- BOOL operator!=(const CGdiObject& obj) const;
- // Implementation
- public:
- virtual ~CGdiObject();
- #ifdef _DEBUG
- virtual void Dump(CDumpContext& dc) const;
- virtual void AssertValid() const;
- #endif
- };
- /////////////////////////////////////////////////////////////////////////////
- // CGdiObject subclasses (drawing tools)
- class CPen : public CGdiObject
- {
- DECLARE_DYNAMIC(CPen)
- public:
- static CPen* PASCAL FromHandle(HPEN hPen);
- // Constructors
- CPen();
- CPen(int nPenStyle, int nWidth, COLORREF crColor);
- CPen(int nPenStyle, int nWidth, const LOGBRUSH* pLogBrush,
- int nStyleCount = 0, const DWORD* lpStyle = NULL);
- BOOL CreatePen(int nPenStyle, int nWidth, COLORREF crColor);
- BOOL CreatePen(int nPenStyle, int nWidth, const LOGBRUSH* pLogBrush,
- int nStyleCount = 0, const DWORD* lpStyle = NULL);
- BOOL CreatePenIndirect(LPLOGPEN lpLogPen);
- // Attributes
- operator HPEN() const;
- int GetLogPen(LOGPEN* pLogPen);
- int GetExtLogPen(EXTLOGPEN* pLogPen);
- // Implementation
- public:
- virtual ~CPen();
- #ifdef _DEBUG
- virtual void Dump(CDumpContext& dc) const;
- #endif
- };
- class CBrush : public CGdiObject
- {
- DECLARE_DYNAMIC(CBrush)
- public:
- static CBrush* PASCAL FromHandle(HBRUSH hBrush);
- // Constructors
- CBrush();
- CBrush(COLORREF crColor); // CreateSolidBrush
- CBrush(int nIndex, COLORREF crColor); // CreateHatchBrush
- CBrush(CBitmap* pBitmap); // CreatePatternBrush
- BOOL CreateSolidBrush(COLORREF crColor);
- BOOL CreateHatchBrush(int nIndex, COLORREF crColor);
- BOOL CreateBrushIndirect(const LOGBRUSH* lpLogBrush);
- BOOL CreatePatternBrush(CBitmap* pBitmap);
- BOOL CreateDIBPatternBrush(HGLOBAL hPackedDIB, UINT nUsage);
- BOOL CreateDIBPatternBrush(const void* lpPackedDIB, UINT nUsage);
- BOOL CreateSysColorBrush(int nIndex);
- // Attributes
- operator HBRUSH() const;
- int GetLogBrush(LOGBRUSH* pLogBrush);
- // Implementation
- public:
- virtual ~CBrush();
- #ifdef _DEBUG
- virtual void Dump(CDumpContext& dc) const;
- #endif
- };
- class CFont : public CGdiObject
- {
- DECLARE_DYNAMIC(CFont)
- public:
- static CFont* PASCAL FromHandle(HFONT hFont);
- // Constructors
- CFont();
- BOOL CreateFontIndirect(const LOGFONT* lpLogFont);
- BOOL CreateFont(int nHeight, int nWidth, int nEscapement,
- int nOrientation, int nWeight, BYTE bItalic, BYTE bUnderline,
- BYTE cStrikeOut, BYTE nCharSet, BYTE nOutPrecision,
- BYTE nClipPrecision, BYTE nQuality, BYTE nPitchAndFamily,
- LPCTSTR lpszFacename);
- BOOL CreatePointFont(int nPointSize, LPCTSTR lpszFaceName, CDC* pDC = NULL);
- BOOL CreatePointFontIndirect(const LOGFONT* lpLogFont, CDC* pDC = NULL);
- // Attributes
- operator HFONT() const;
- int GetLogFont(LOGFONT* pLogFont);
- // Implementation
- public:
- virtual ~CFont();
- #ifdef _DEBUG
- virtual void Dump(CDumpContext& dc) const;
- #endif
- };
- class CBitmap : public CGdiObject
- {
- DECLARE_DYNAMIC(CBitmap)
- public:
- static CBitmap* PASCAL FromHandle(HBITMAP hBitmap);
- // Constructors
- CBitmap();
- BOOL LoadBitmap(LPCTSTR lpszResourceName);
- BOOL LoadBitmap(UINT nIDResource);
- BOOL LoadOEMBitmap(UINT nIDBitmap); // for OBM_/OCR_/OIC_
- BOOL LoadMappedBitmap(UINT nIDBitmap, UINT nFlags = 0,
- LPCOLORMAP lpColorMap = NULL, int nMapSize = 0);
- BOOL CreateBitmap(int nWidth, int nHeight, UINT nPlanes, UINT nBitcount,
- const void* lpBits);
- BOOL CreateBitmapIndirect(LPBITMAP lpBitmap);
- BOOL CreateCompatibleBitmap(CDC* pDC, int nWidth, int nHeight);
- BOOL CreateDiscardableBitmap(CDC* pDC, int nWidth, int nHeight);
- // Attributes
- operator HBITMAP() const;
- int GetBitmap(BITMAP* pBitMap);
- // Operations
- DWORD SetBitmapBits(DWORD dwCount, const void* lpBits);
- DWORD GetBitmapBits(DWORD dwCount, LPVOID lpBits) const;
- CSize SetBitmapDimension(int nWidth, int nHeight);
- CSize GetBitmapDimension() const;
- // Implementation
- public:
- virtual ~CBitmap();
- #ifdef _DEBUG
- virtual void Dump(CDumpContext& dc) const;
- #endif
- };
- class CPalette : public CGdiObject
- {
- DECLARE_DYNAMIC(CPalette)
- public:
- static CPalette* PASCAL FromHandle(HPALETTE hPalette);
- // Constructors
- CPalette();
- BOOL CreatePalette(LPLOGPALETTE lpLogPalette);
- BOOL CreateHalftonePalette(CDC* pDC);
- // Attributes
- operator HPALETTE() const;
- int GetEntryCount();
- UINT GetPaletteEntries(UINT nStartIndex, UINT nNumEntries,
- LPPALETTEENTRY lpPaletteColors) const;
- UINT SetPaletteEntries(UINT nStartIndex, UINT nNumEntries,
- LPPALETTEENTRY lpPaletteColors);
- // Operations
- void AnimatePalette(UINT nStartIndex, UINT nNumEntries,
- LPPALETTEENTRY lpPaletteColors);
- UINT GetNearestPaletteIndex(COLORREF crColor) const;
- BOOL ResizePalette(UINT nNumEntries);
- // Implementation
- virtual ~CPalette();
- };
- class CRgn : public CGdiObject
- {
- DECLARE_DYNAMIC(CRgn)
- public:
- static CRgn* PASCAL FromHandle(HRGN hRgn);
- operator HRGN() const;
- // Constructors
- CRgn();
- BOOL CreateRectRgn(int x1, int y1, int x2, int y2);
- BOOL CreateRectRgnIndirect(LPCRECT lpRect);
- BOOL CreateEllipticRgn(int x1, int y1, int x2, int y2);
- BOOL CreateEllipticRgnIndirect(LPCRECT lpRect);
- BOOL CreatePolygonRgn(LPPOINT lpPoints, int nCount, int nMode);
- BOOL CreatePolyPolygonRgn(LPPOINT lpPoints, LPINT lpPolyCounts,
- int nCount, int nPolyFillMode);
- BOOL CreateRoundRectRgn(int x1, int y1, int x2, int y2, int x3, int y3);
- BOOL CreateFromPath(CDC* pDC);
- BOOL CreateFromData(const XFORM* lpXForm, int nCount,
- const RGNDATA* pRgnData);
- // Operations
- void SetRectRgn(int x1, int y1, int x2, int y2);
- void SetRectRgn(LPCRECT lpRect);
- int CombineRgn(CRgn* pRgn1, CRgn* pRgn2, int nCombineMode);
- int CopyRgn(CRgn* pRgnSrc);
- BOOL EqualRgn(CRgn* pRgn) const;
- int OffsetRgn(int x, int y);
- int OffsetRgn(POINT point);
- int GetRgnBox(LPRECT lpRect) const;
- BOOL PtInRegion(int x, int y) const;
- BOOL PtInRegion(POINT point) const;
- BOOL RectInRegion(LPCRECT lpRect) const;
- int GetRegionData(LPRGNDATA lpRgnData, int nCount) const;
- // Implementation
- virtual ~CRgn();
- };
- /////////////////////////////////////////////////////////////////////////////
- // The device context
- class CDC : public CObject
- {
- DECLARE_DYNCREATE(CDC)
- public:
- // Attributes
- HDC m_hDC; // The output DC (must be first data member)
- HDC m_hAttribDC; // The Attribute DC
- operator HDC() const;
- HDC GetSafeHdc() const; // Always returns the Output DC
- CWnd* GetWindow() const;
- static CDC* PASCAL FromHandle(HDC hDC);
- static void PASCAL DeleteTempMap();
- BOOL Attach(HDC hDC); // Attach/Detach affects only the Output DC
- HDC Detach();
- virtual void SetAttribDC(HDC hDC); // Set the Attribute DC
- virtual void SetOutputDC(HDC hDC); // Set the Output DC
- virtual void ReleaseAttribDC(); // Release the Attribute DC
- virtual void ReleaseOutputDC(); // Release the Output DC
- BOOL IsPrinting() const; // TRUE if being used for printing
- CPen* GetCurrentPen() const;
- CBrush* GetCurrentBrush() const;
- CPalette* GetCurrentPalette() const;
- CFont* GetCurrentFont() const;
- CBitmap* GetCurrentBitmap() const;
- // for bidi and mirrored localization
- DWORD GetLayout() const;
- DWORD SetLayout(DWORD dwLayout);
- // Constructors
- CDC();
- BOOL CreateDC(LPCTSTR lpszDriverName, LPCTSTR lpszDeviceName,
- LPCTSTR lpszOutput, const void* lpInitData);
- BOOL CreateIC(LPCTSTR lpszDriverName, LPCTSTR lpszDeviceName,
- LPCTSTR lpszOutput, const void* lpInitData);
- BOOL CreateCompatibleDC(CDC* pDC);
- BOOL DeleteDC();
- // Device-Context Functions
- virtual int SaveDC();
- virtual BOOL RestoreDC(int nSavedDC);
- int GetDeviceCaps(int nIndex) const;
- UINT SetBoundsRect(LPCRECT lpRectBounds, UINT flags);
- UINT GetBoundsRect(LPRECT lpRectBounds, UINT flags);
- BOOL ResetDC(const DEVMODE* lpDevMode);
- // Drawing-Tool Functions
- CPoint GetBrushOrg() const;
- CPoint SetBrushOrg(int x, int y);
- CPoint SetBrushOrg(POINT point);
- int EnumObjects(int nObjectType,
- int (CALLBACK* lpfn)(LPVOID, LPARAM), LPARAM lpData);
- // Type-safe selection helpers
- public:
- virtual CGdiObject* SelectStockObject(int nIndex);
- CPen* SelectObject(CPen* pPen);
- CBrush* SelectObject(CBrush* pBrush);
- virtual CFont* SelectObject(CFont* pFont);
- CBitmap* SelectObject(CBitmap* pBitmap);
- int SelectObject(CRgn* pRgn); // special return for regions
- CGdiObject* SelectObject(CGdiObject* pObject);
- // CGdiObject* provided so compiler doesn't use SelectObject(HGDIOBJ)
- // Color and Color Palette Functions
- COLORREF GetNearestColor(COLORREF crColor) const;
- CPalette* SelectPalette(CPalette* pPalette, BOOL bForceBackground);
- UINT RealizePalette();
- void UpdateColors();
- // Drawing-Attribute Functions
- COLORREF GetBkColor() const;
- int GetBkMode() const;
- int GetPolyFillMode() const;
- int GetROP2() const;
- int GetStretchBltMode() const;
- COLORREF GetTextColor() const;
- virtual COLORREF SetBkColor(COLORREF crColor);
- int SetBkMode(int nBkMode);
- int SetPolyFillMode(int nPolyFillMode);
- int SetROP2(int nDrawMode);
- int SetStretchBltMode(int nStretchMode);
- virtual COLORREF SetTextColor(COLORREF crColor);
- BOOL GetColorAdjustment(LPCOLORADJUSTMENT lpColorAdjust) const;
- BOOL SetColorAdjustment(const COLORADJUSTMENT* lpColorAdjust);
- // Mapping Functions
- int GetMapMode() const;
- CPoint GetViewportOrg() const;
- virtual int SetMapMode(int nMapMode);
- // Viewport Origin
- virtual CPoint SetViewportOrg(int x, int y);
- CPoint SetViewportOrg(POINT point);
- virtual CPoint OffsetViewportOrg(int nWidth, int nHeight);
- // Viewport Extent
- CSize GetViewportExt() const;
- virtual CSize SetViewportExt(int cx, int cy);
- CSize SetViewportExt(SIZE size);
- virtual CSize ScaleViewportExt(int xNum, int xDenom, int yNum, int yDenom);
- // Window Origin
- CPoint GetWindowOrg() const;
- CPoint SetWindowOrg(int x, int y);
- CPoint SetWindowOrg(POINT point);
- CPoint OffsetWindowOrg(int nWidth, int nHeight);
- // Window extent
- CSize GetWindowExt() const;
- virtual CSize SetWindowExt(int cx, int cy);
- CSize SetWindowExt(SIZE size);
- virtual CSize ScaleWindowExt(int xNum, int xDenom, int yNum, int yDenom);
- // Coordinate Functions
- void DPtoLP(LPPOINT lpPoints, int nCount = 1) const;
- void DPtoLP(LPRECT lpRect) const;
- void DPtoLP(LPSIZE lpSize) const;
- void LPtoDP(LPPOINT lpPoints, int nCount = 1) const;
- void LPtoDP(LPRECT lpRect) const;
- void LPtoDP(LPSIZE lpSize) const;
- // Special Coordinate Functions (useful for dealing with metafiles and OLE)
- void DPtoHIMETRIC(LPSIZE lpSize) const;
- void LPtoHIMETRIC(LPSIZE lpSize) const;
- void HIMETRICtoDP(LPSIZE lpSize) const;
- void HIMETRICtoLP(LPSIZE lpSize) const;
- // Region Functions
- BOOL FillRgn(CRgn* pRgn, CBrush* pBrush);
- BOOL FrameRgn(CRgn* pRgn, CBrush* pBrush, int nWidth, int nHeight);
- BOOL InvertRgn(CRgn* pRgn);
- BOOL PaintRgn(CRgn* pRgn);
- // Clipping Functions
- virtual int GetClipBox(LPRECT lpRect) const;
- virtual BOOL PtVisible(int x, int y) const;
- BOOL PtVisible(POINT point) const;
- virtual BOOL RectVisible(LPCRECT lpRect) const;
- int SelectClipRgn(CRgn* pRgn);
- int ExcludeClipRect(int x1, int y1, int x2, int y2);
- int ExcludeClipRect(LPCRECT lpRect);
- int ExcludeUpdateRgn(CWnd* pWnd);
- int IntersectClipRect(int x1, int y1, int x2, int y2);
- int IntersectClipRect(LPCRECT lpRect);
- int OffsetClipRgn(int x, int y);
- int OffsetClipRgn(SIZE size);
- int SelectClipRgn(CRgn* pRgn, int nMode);
- // Line-Output Functions
- CPoint GetCurrentPosition() const;
- CPoint MoveTo(int x, int y);
- CPoint MoveTo(POINT point);
- BOOL LineTo(int x, int y);
- BOOL LineTo(POINT point);
- BOOL Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
- BOOL Arc(LPCRECT lpRect, POINT ptStart, POINT ptEnd);
- BOOL Polyline(LPPOINT lpPoints, int nCount);
- BOOL AngleArc(int x, int y, int nRadius, float fStartAngle, float fSweepAngle);
- BOOL ArcTo(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
- BOOL ArcTo(LPCRECT lpRect, POINT ptStart, POINT ptEnd);
- int GetArcDirection() const;
- int SetArcDirection(int nArcDirection);
- BOOL PolyDraw(const POINT* lpPoints, const BYTE* lpTypes, int nCount);
- BOOL PolylineTo(const POINT* lpPoints, int nCount);
- BOOL PolyPolyline(const POINT* lpPoints,
- const DWORD* lpPolyPoints, int nCount);
- BOOL PolyBezier(const POINT* lpPoints, int nCount);
- BOOL PolyBezierTo(const POINT* lpPoints, int nCount);
- // Simple Drawing Functions
- void FillRect(LPCRECT lpRect, CBrush* pBrush);
- void FrameRect(LPCRECT lpRect, CBrush* pBrush);
- void InvertRect(LPCRECT lpRect);
- BOOL DrawIcon(int x, int y, HICON hIcon);
- BOOL DrawIcon(POINT point, HICON hIcon);
- #if (WINVER >= 0x400)
- BOOL DrawState(CPoint pt, CSize size, HBITMAP hBitmap, UINT nFlags,
- HBRUSH hBrush = NULL);
- BOOL DrawState(CPoint pt, CSize size, CBitmap* pBitmap, UINT nFlags,
- CBrush* pBrush = NULL);
- BOOL DrawState(CPoint pt, CSize size, HICON hIcon, UINT nFlags,
- HBRUSH hBrush = NULL);
- BOOL DrawState(CPoint pt, CSize size, HICON hIcon, UINT nFlags,
- CBrush* pBrush = NULL);
- BOOL DrawState(CPoint pt, CSize size, LPCTSTR lpszText, UINT nFlags,
- BOOL bPrefixText = TRUE, int nTextLen = 0, HBRUSH hBrush = NULL);
- BOOL DrawState(CPoint pt, CSize size, LPCTSTR lpszText, UINT nFlags,
- BOOL bPrefixText = TRUE, int nTextLen = 0, CBrush* pBrush = NULL);
- BOOL DrawState(CPoint pt, CSize size, DRAWSTATEPROC lpDrawProc,
- LPARAM lData, UINT nFlags, HBRUSH hBrush = NULL);
- BOOL DrawState(CPoint pt, CSize size, DRAWSTATEPROC lpDrawProc,
- LPARAM lData, UINT nFlags, CBrush* pBrush = NULL);
- #endif
- // Ellipse and Polygon Functions
- BOOL Chord(int x1, int y1, int x2, int y2, int x3, int y3,
- int x4, int y4);
- BOOL Chord(LPCRECT lpRect, POINT ptStart, POINT ptEnd);
- void DrawFocusRect(LPCRECT lpRect);
- BOOL Ellipse(int x1, int y1, int x2, int y2);
- BOOL Ellipse(LPCRECT lpRect);
- BOOL Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
- BOOL Pie(LPCRECT lpRect, POINT ptStart, POINT ptEnd);
- BOOL Polygon(LPPOINT lpPoints, int nCount);
- BOOL PolyPolygon(LPPOINT lpPoints, LPINT lpPolyCounts, int nCount);
- BOOL Rectangle(int x1, int y1, int x2, int y2);
- BOOL Rectangle(LPCRECT lpRect);
- BOOL RoundRect(int x1, int y1, int x2, int y2, int x3, int y3);
- BOOL RoundRect(LPCRECT lpRect, POINT point);
- // Bitmap Functions
- BOOL PatBlt(int x, int y, int nWidth, int nHeight, DWORD dwRop);
- BOOL BitBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC,
- int xSrc, int ySrc, DWORD dwRop);
- BOOL StretchBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC,
- int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, DWORD dwRop);
- COLORREF GetPixel(int x, int y) const;
- COLORREF GetPixel(POINT point) const;
- COLORREF SetPixel(int x, int y, COLORREF crColor);
- COLORREF SetPixel(POINT point, COLORREF crColor);
- BOOL FloodFill(int x, int y, COLORREF crColor);
- BOOL ExtFloodFill(int x, int y, COLORREF crColor, UINT nFillType);
- BOOL MaskBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC,
- int xSrc, int ySrc, CBitmap& maskBitmap, int xMask, int yMask,
- DWORD dwRop);
- BOOL PlgBlt(LPPOINT lpPoint, CDC* pSrcDC, int xSrc, int ySrc,
- int nWidth, int nHeight, CBitmap& maskBitmap, int xMask, int yMask);
- BOOL SetPixelV(int x, int y, COLORREF crColor);
- BOOL SetPixelV(POINT point, COLORREF crColor);
- // Text Functions
- virtual BOOL TextOut(int x, int y, LPCTSTR lpszString, int nCount);
- BOOL TextOut(int x, int y, const CString& str);
- virtual BOOL ExtTextOut(int x, int y, UINT nOptions, LPCRECT lpRect,
- LPCTSTR lpszString, UINT nCount, LPINT lpDxWidths);
- BOOL ExtTextOut(int x, int y, UINT nOptions, LPCRECT lpRect,
- const CString& str, LPINT lpDxWidths);
- virtual CSize TabbedTextOut(int x, int y, LPCTSTR lpszString, int nCount,
- int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin);
- CSize TabbedTextOut(int x, int y, const CString& str,
- int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin);
- virtual int DrawText(LPCTSTR lpszString, int nCount, LPRECT lpRect,
- UINT nFormat);
- int DrawText(const CString& str, LPRECT lpRect, UINT nFormat);
- CSize GetTextExtent(LPCTSTR lpszString, int nCount) const;
- CSize GetTextExtent(const CString& str) const;
- CSize GetOutputTextExtent(LPCTSTR lpszString, int nCount) const;
- CSize GetOutputTextExtent(const CString& str) const;
- CSize GetTabbedTextExtent(LPCTSTR lpszString, int nCount,
- int nTabPositions, LPINT lpnTabStopPositions) const;
- CSize GetTabbedTextExtent(const CString& str,
- int nTabPositions, LPINT lpnTabStopPositions) const;
- CSize GetOutputTabbedTextExtent(LPCTSTR lpszString, int nCount,
- int nTabPositions, LPINT lpnTabStopPositions) const;
- CSize GetOutputTabbedTextExtent(const CString& str,
- int nTabPositions, LPINT lpnTabStopPositions) const;
- virtual BOOL GrayString(CBrush* pBrush,
- BOOL (CALLBACK* lpfnOutput)(HDC, LPARAM, int), LPARAM lpData,
- int nCount, int x, int y, int nWidth, int nHeight);
- UINT GetTextAlign() const;
- UINT SetTextAlign(UINT nFlags);
- int GetTextFace(int nCount, LPTSTR lpszFacename) const;
- int GetTextFace(CString& rString) const;
- BOOL GetTextMetrics(LPTEXTMETRIC lpMetrics) const;
- BOOL GetOutputTextMetrics(LPTEXTMETRIC lpMetrics) const;
- int SetTextJustification(int nBreakExtra, int nBreakCount);
- int GetTextCharacterExtra() const;
- int SetTextCharacterExtra(int nCharExtra);
- // Advanced Drawing
- #if (WINVER >= 0x400)
- BOOL DrawEdge(LPRECT lpRect, UINT nEdge, UINT nFlags);
- BOOL DrawFrameControl(LPRECT lpRect, UINT nType, UINT nState);
- #endif
- // Scrolling Functions
- BOOL ScrollDC(int dx, int dy, LPCRECT lpRectScroll, LPCRECT lpRectClip,
- CRgn* pRgnUpdate, LPRECT lpRectUpdate);
- // Font Functions
- BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const;
- BOOL GetOutputCharWidth(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const;
- DWORD SetMapperFlags(DWORD dwFlag);
- CSize GetAspectRatioFilter() const;
- BOOL GetCharABCWidths(UINT nFirstChar, UINT nLastChar, LPABC lpabc) const;
- DWORD GetFontData(DWORD dwTable, DWORD dwOffset, LPVOID lpData, DWORD cbData) const;
- int GetKerningPairs(int nPairs, LPKERNINGPAIR lpkrnpair) const;
- UINT GetOutlineTextMetrics(UINT cbData, LPOUTLINETEXTMETRIC lpotm) const;
- DWORD GetGlyphOutline(UINT nChar, UINT nFormat, LPGLYPHMETRICS lpgm,
- DWORD cbBuffer, LPVOID lpBuffer, const MAT2* lpmat2) const;
- BOOL GetCharABCWidths(UINT nFirstChar, UINT nLastChar,
- LPABCFLOAT lpABCF) const;
- BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar,
- float* lpFloatBuffer) const;
- // Printer/Device Escape Functions
- virtual int Escape(int nEscape, int nCount,
- LPCSTR lpszInData, LPVOID lpOutData);
- int Escape(int nEscape, int nInputSize, LPCSTR lpszInputData,
- int nOutputSize, LPSTR lpszOutputData);
- int DrawEscape(int nEscape, int nInputSize, LPCSTR lpszInputData);
- // Escape helpers
- int StartDoc(LPCTSTR lpszDocName); // old Win3.0 version
- int StartDoc(LPDOCINFO lpDocInfo);
- int StartPage();
- int EndPage();
- int SetAbortProc(BOOL (CALLBACK* lpfn)(HDC, int));
- int AbortDoc();
- int EndDoc();
- // MetaFile Functions
- BOOL PlayMetaFile(HMETAFILE hMF);
- BOOL PlayMetaFile(HENHMETAFILE hEnhMetaFile, LPCRECT lpBounds);
- BOOL AddMetaFileComment(UINT nDataSize, const BYTE* pCommentData);
- // can be used for enhanced metafiles only
- // Path Functions
- BOOL AbortPath();
- BOOL BeginPath();
- BOOL CloseFigure();
- BOOL EndPath();
- BOOL FillPath();
- BOOL FlattenPath();
- BOOL StrokeAndFillPath();
- BOOL StrokePath();
- BOOL WidenPath();
- float GetMiterLimit() const;
- BOOL SetMiterLimit(float fMiterLimit);
- int GetPath(LPPOINT lpPoints, LPBYTE lpTypes, int nCount) const;
- BOOL SelectClipPath(int nMode);
- // Misc Helper Functions
- static CBrush* PASCAL GetHalftoneBrush();
- void DrawDragRect(LPCRECT lpRect, SIZE size,
- LPCRECT lpRectLast, SIZE sizeLast,
- CBrush* pBrush = NULL, CBrush* pBrushLast = NULL);
- void FillSolidRect(LPCRECT lpRect, COLORREF clr);
- void FillSolidRect(int x, int y, int cx, int cy, COLORREF clr);
- void Draw3dRect(LPCRECT lpRect, COLORREF clrTopLeft, COLORREF clrBottomRight);
- void Draw3dRect(int x, int y, int cx, int cy,
- COLORREF clrTopLeft, COLORREF clrBottomRight);
- // Implementation
- public:
- virtual ~CDC();
- #ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
- #endif
- // advanced use and implementation
- BOOL m_bPrinting;
- HGDIOBJ SelectObject(HGDIOBJ); // do not use for regions
- protected:
- // used for implementation of non-virtual SelectObject calls
- static CGdiObject* PASCAL SelectGdiObject(HDC hDC, HGDIOBJ h);
- };
- /////////////////////////////////////////////////////////////////////////////
- // CDC Helpers
- class CPaintDC : public CDC
- {
- DECLARE_DYNAMIC(CPaintDC)
- // Constructors
- public:
- CPaintDC(CWnd* pWnd); // BeginPaint
- // Attributes
- protected:
- HWND m_hWnd;
- public:
- PAINTSTRUCT m_ps; // actual paint struct!
- // Implementation
- public:
- virtual ~CPaintDC();
- #ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
- #endif
- };
- class CClientDC : public CDC
- {
- DECLARE_DYNAMIC(CClientDC)
- // Constructors
- public:
- CClientDC(CWnd* pWnd);
- // Attributes
- protected:
- HWND m_hWnd;
- // Implementation
- public:
- virtual ~CClientDC();
- #ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
- #endif
- };
- class CWindowDC : public CDC
- {
- DECLARE_DYNAMIC(CWindowDC)
- // Constructors
- public:
- CWindowDC(CWnd* pWnd);
- // Attributes
- protected:
- HWND m_hWnd;
- // Implementation
- public:
- virtual ~CWindowDC();
- #ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
- #endif
- };
- /////////////////////////////////////////////////////////////////////////////
- // CMenu
- class CMenu : public CObject
- {
- DECLARE_DYNCREATE(CMenu)
- public:
- // Constructors
- CMenu();
- BOOL CreateMenu();
- BOOL CreatePopupMenu();
- BOOL LoadMenu(LPCTSTR lpszResourceName);
- BOOL LoadMenu(UINT nIDResource);
- BOOL LoadMenuIndirect(const void* lpMenuTemplate);
- BOOL DestroyMenu();
- // Attributes
- HMENU m_hMenu; // must be first data member
- HMENU GetSafeHmenu() const;
- operator HMENU() const;
- static CMenu* PASCAL FromHandle(HMENU hMenu);
- static void PASCAL DeleteTempMap();
- BOOL Attach(HMENU hMenu);
- HMENU Detach();
- // CMenu Operations
- BOOL DeleteMenu(UINT nPosition, UINT nFlags);
- BOOL TrackPopupMenu(UINT nFlags, int x, int y,
- CWnd* pWnd, LPCRECT lpRect = 0);
- BOOL operator==(const CMenu& menu) const;
- BOOL operator!=(const CMenu& menu) const;
- // CMenuItem Operations
- BOOL AppendMenu(UINT nFlags, UINT nIDNewItem = 0,
- LPCTSTR lpszNewItem = NULL);
- BOOL AppendMenu(UINT nFlags, UINT nIDNewItem, const CBitmap* pBmp);
- UINT CheckMenuItem(UINT nIDCheckItem, UINT nCheck);
- UINT EnableMenuItem(UINT nIDEnableItem, UINT nEnable);
- UINT GetMenuItemCount() const;
- UINT GetMenuItemID(int nPos) const;
- UINT GetMenuState(UINT nID, UINT nFlags) const;
- int GetMenuString(UINT nIDItem, LPTSTR lpString, int nMaxCount,
- UINT nFlags) const;
- int GetMenuString(UINT nIDItem, CString& rString, UINT nFlags) const;
- BOOL GetMenuItemInfo(UINT nIDItem, LPMENUITEMINFO lpMenuItemInfo,
- BOOL fByPos = FALSE);
- CMenu* GetSubMenu(int nPos) const;
- BOOL InsertMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem = 0,
- LPCTSTR lpszNewItem = NULL);
- BOOL InsertMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem,
- const CBitmap* pBmp);
- BOOL ModifyMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem = 0,
- LPCTSTR lpszNewItem = NULL);
- BOOL ModifyMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem,
- const CBitmap* pBmp);
- BOOL RemoveMenu(UINT nPosition, UINT nFlags);
- BOOL SetMenuItemBitmaps(UINT nPosition, UINT nFlags,
- const CBitmap* pBmpUnchecked, const CBitmap* pBmpChecked);
- BOOL CheckMenuRadioItem(UINT nIDFirst, UINT nIDLast, UINT nIDItem, UINT nFlags);
- BOOL SetDefaultItem(UINT uItem, BOOL fByPos = FALSE);
- UINT GetDefaultItem(UINT gmdiFlags, BOOL fByPos = FALSE);
- // Context Help Functions
- BOOL SetMenuContextHelpId(DWORD dwContextHelpId);
- DWORD GetMenuContextHelpId() const;
- // Overridables (must override draw and measure for owner-draw menu items)
- virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
- virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
- // Implementation
- public:
- virtual ~CMenu();
- #ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
- #endif
- static CMenu* PASCAL CMenu::FromHandlePermanent(HMENU hMenu);
- };
- /////////////////////////////////////////////////////////////////////////////
- // Window message map handling
- struct AFX_MSGMAP_ENTRY; // declared below after CWnd
- struct AFX_MSGMAP
- {
- #ifdef _AFXDLL
- const AFX_MSGMAP* (PASCAL* pfnGetBaseMap)();
- #else
- const AFX_MSGMAP* pBaseMap;
- #endif
- const AFX_MSGMAP_ENTRY* lpEntries;
- };
- #ifdef _AFXDLL
- #define DECLARE_MESSAGE_MAP() \
- private: \
- static const AFX_MSGMAP_ENTRY _messageEntries[]; \
- protected: \
- static AFX_DATA const AFX_MSGMAP messageMap; \
- static const AFX_MSGMAP* PASCAL _GetBaseMessageMap(); \
- virtual const AFX_MSGMAP* GetMessageMap() const; \
- #else
- #define DECLARE_MESSAGE_MAP() \
- private: \
- static const AFX_MSGMAP_ENTRY _messageEntries[]; \
- protected: \
- static AFX_DATA const AFX_MSGMAP messageMap; \
- virtual const AFX_MSGMAP* GetMessageMap() const; \
- #endif
- #ifdef _AFXDLL
- #define BEGIN_MESSAGE_MAP(theClass, baseClass) \
- const AFX_MSGMAP* PASCAL theClass::_GetBaseMessageMap() \
- { return &baseClass::messageMap; } \
- const AFX_MSGMAP* theClass::GetMessageMap() const \
- { return &theClass::messageMap; } \
- AFX_COMDAT AFX_DATADEF const AFX_MSGMAP theClass::messageMap = \
- { &theClass::_GetBaseMessageMap, &theClass::_messageEntries[0] }; \
- AFX_COMDAT const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = \
- { \
- #else
- #define BEGIN_MESSAGE_MAP(theClass, baseClass) \
- const AFX_MSGMAP* theClass::GetMessageMap() const \
- { return &theClass::messageMap; } \
- AFX_COMDAT AFX_DATADEF const AFX_MSGMAP theClass::messageMap = \
- { &baseClass::messageMap, &theClass::_messageEntries[0] }; \
- AFX_COMDAT const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = \
- { \
- #endif
- #define END_MESSAGE_MAP() \
- {0, 0, 0, 0, AfxSig_end, (AFX_PMSG)0 } \
- }; \
- // Message map signature values and macros in separate header
- #include <afxmsg_.h>
- /////////////////////////////////////////////////////////////////////////////
- // Dialog data exchange (DDX_) and validation (DDV_)
- // CDataExchange - for data exchange and validation
- class CDataExchange
- {
- // Attributes
- public:
- BOOL m_bSaveAndValidate; // TRUE => save and validate data
- CWnd* m_pDlgWnd; // container usually a dialog
- // Operations (for implementors of DDX and DDV procs)
- HWND PrepareCtrl(int nIDC); // return HWND of control
- HWND PrepareEditCtrl(int nIDC); // return HWND of control
- void Fail(); // will throw exception
- #ifndef _AFX_NO_OCC_SUPPORT
- CWnd* PrepareOleCtrl(int nIDC); // for OLE controls in dialog
- #endif
- // Implementation
- CDataExchange(CWnd* pDlgWnd, BOOL bSaveAndValidate);
- HWND m_hWndLastControl; // last control used (for validation)
- BOOL m_bEditLastControl; // last control was an edit item
- };
- #include <afxdd_.h> // standard DDX_ and DDV_ routines
- /////////////////////////////////////////////////////////////////////////////
- // OLE types
- typedef LONG HRESULT;
- struct IUnknown;
- typedef IUnknown* LPUNKNOWN;
- struct IDispatch;
- typedef IDispatch* LPDISPATCH;
- struct IConnectionPoint;
- typedef IConnectionPoint* LPCONNECTIONPOINT;
- struct IEnumOLEVERB;
- typedef IEnumOLEVERB* LPENUMOLEVERB;
- typedef struct _GUID GUID;
- typedef GUID IID;
- typedef GUID CLSID;
- #ifndef _REFCLSID_DEFINED
- #define REFCLSID const CLSID &
- #endif
- typedef long DISPID;
- typedef unsigned short VARTYPE;
- typedef long SCODE;
- #if defined(WIN32) && !defined(OLE2ANSI)
- typedef WCHAR OLECHAR;
- #else
- typedef char OLECHAR;
- #endif
- typedef OLECHAR* BSTR;
- struct tagDISPPARAMS;
- typedef tagDISPPARAMS DISPPARAMS;
- struct tagVARIANT;
- typedef tagVARIANT VARIANT;
- struct ITypeInfo;
- typedef ITypeInfo* LPTYPEINFO;
- struct ITypeLib;
- typedef ITypeLib* LPTYPELIB;
- /////////////////////////////////////////////////////////////////////////////
- // CCmdTarget
- // private structures
- struct AFX_CMDHANDLERINFO; // info about where the command is handled
- struct AFX_EVENT; // info about an event
- class CTypeLibCache; // cache for OLE type libraries
- /////////////////////////////////////////////////////////////////////////////
- // OLE interface map handling (more in AFXDISP.H)
- #ifndef _AFX_NO_OLE_SUPPORT
- struct AFX_INTERFACEMAP_ENTRY
- {
- const void* piid; // the interface id (IID) (NULL for aggregate)
- size_t nOffset; // offset of the interface vtable from m_unknown
- };
- struct AFX_INTERFACEMAP
- {
- #ifdef _AFXDLL
- const AFX_INTERFACEMAP* (PASCAL* pfnGetBaseMap)(); // NULL is root class
- #else
- const AFX_INTERFACEMAP* pBaseMap;
- #endif
- const AFX_INTERFACEMAP_ENTRY* pEntry; // map for this class
- };
- #ifdef _AFXDLL
- #define DECLARE_INTERFACE_MAP() \
- private: \
- static const AFX_INTERFACEMAP_ENTRY _interfaceEntries[]; \
- protected: \
- static AFX_DATA const AFX_INTERFACEMAP interfaceMap; \
- static const AFX_INTERFACEMAP* PASCAL _GetBaseInterfaceMap(); \
- virtual const AFX_INTERFACEMAP* GetInterfaceMap() const; \
- #else
- #define DECLARE_INTERFACE_MAP() \
- private: \
- static const AFX_INTERFACEMAP_ENTRY _interfaceEntries[]; \
- protected: \
- static AFX_DATA const AFX_INTERFACEMAP interfaceMap; \
- virtual const AFX_INTERFACEMAP* GetInterfaceMap() const; \
- #endif
- #endif //!_AFX_NO_OLE_SUPPORT
- /////////////////////////////////////////////////////////////////////////////
- // OLE dispatch map handling (more in AFXDISP.H)
- #ifndef _AFX_NO_OLE_SUPPORT
- struct AFX_DISPMAP_ENTRY;
- struct AFX_DISPMAP
- {
- #ifdef _AFXDLL
- const AFX_DISPMAP* (PASCAL* pfnGetBaseMap)();
- #else
- const AFX_DISPMAP* pBaseMap;
- #endif
- const AFX_DISPMAP_ENTRY* lpEntries;
- UINT* lpEntryCount;
- DWORD* lpStockPropMask;
- };
- #ifdef _AFXDLL
- #define DECLARE_DISPATCH_MAP() \
- private: \
- static const AFX_DISPMAP_ENTRY _dispatchEntries[]; \
- static UINT _dispatchEntryCount; \
- static DWORD _dwStockPropMask; \
- protected: \
- static AFX_DATA const AFX_DISPMAP dispatchMap; \
- static const AFX_DISPMAP* PASCAL _GetBaseDispatchMap(); \
- virtual const AFX_DISPMAP* GetDispatchMap() const; \
- #else
- #define DECLARE_DISPATCH_MAP() \
- private: \
- static const AFX_DISPMAP_ENTRY _dispatchEntries[]; \
- static UINT _dispatchEntryCount; \
- static DWORD _dwStockPropMask; \
- protected: \
- static AFX_DATA const AFX_DISPMAP dispatchMap; \
- virtual const AFX_DISPMAP* GetDispatchMap() const; \
- #endif
- #endif //!_AFX_NO_OLE_SUPPORT
- /////////////////////////////////////////////////////////////////////////////
- // OLE Document Object command target handling
- #ifndef _AFX_NO_DOCOBJECT_SUPPORT
- struct AFX_OLECMDMAP_ENTRY
- {
- const GUID* pguid; // id of the command group
- ULONG cmdID; // OLECMD ID
- UINT nID; // corresponding WM_COMMAND message ID
- };
- struct AFX_OLECMDMAP
- {
- #ifdef _AFXDLL
- const AFX_OLECMDMAP* (PASCAL* pfnGetBaseMap)();
- #else
- const AFX_OLECMDMAP* pBaseMap;
- #endif
- const AFX_OLECMDMAP_ENTRY* lpEntries;
- };
- #ifdef _AFXDLL
- #define DECLARE_OLECMD_MAP() \
- private: \
- static const AFX_OLECMDMAP_ENTRY _commandEntries[]; \
- protected: \
- static AFX_DATA const AFX_OLECMDMAP commandMap; \
- static const AFX_OLECMDMAP* PASCAL _GetBaseCommandMap(); \
- virtual const AFX_OLECMDMAP* GetCommandMap() const; \
- #else
- #define DECLARE_OLECMD_MAP() \
- private: \
- static const AFX_OLECMDMAP_ENTRY _commandEntries[]; \
- protected: \
- static AFX_DATA const AFX_OLECMDMAP commandMap; \
- virtual const AFX_OLECMDMAP* GetCommandMap() const; \
- #endif
- #ifdef _AFXDLL
- #define BEGIN_OLECMD_MAP(theClass, baseClass) \
- const AFX_OLECMDMAP* PASCAL theClass::_GetBaseCommandMap() \
- { return &baseClass::commandMap; } \
- const AFX_OLECMDMAP* theClass::GetCommandMap() const \
- { return &theClass::commandMap; } \
- AFX_COMDAT AFX_DATADEF const AFX_OLECMDMAP theClass::commandMap = \
- { &theClass::_GetBaseCommandMap, &theClass::_commandEntries[0] }; \
- AFX_COMDAT const AFX_OLECMDMAP_ENTRY theClass::_commandEntries[] = \
- { \
- #else
- #define BEGIN_OLECMD_MAP(theClass, baseClass) \
- const AFX_OLECMDMAP* theClass::GetCommandMap() const \
- { return &theClass::commandMap; } \
- AFX_COMDAT AFX_DATADEF const AFX_OLECMDMAP theClass::commandMap = \
- { &baseClass::commandMap, &theClass::_commandEntries[0] }; \
- AFX_COMDAT const AFX_OLECMDMAP_ENTRY theClass::_commandEntries[] = \
- { \
- #endif
- #define END_OLECMD_MAP() \
- {NULL, 0, 0} \
- }; \
- class COleCmdUI;
- #endif //!_AFX_NO_DOCOBJECT_SUPPORT
- /////////////////////////////////////////////////////////////////////////////
- // OLE event sink map handling (more in AFXDISP.H)
- //#ifndef _AFX_NO_OCC_SUPPORT
- struct AFX_EVENTSINKMAP_ENTRY;
- struct AFX_EVENTSINKMAP
- {
- #ifdef _AFXDLL
- const AFX_EVENTSINKMAP* (PASCAL* pfnGetBaseMap)();
- #else
- const AFX_EVENTSINKMAP* pBaseMap;
- #endif
- const AFX_EVENTSINKMAP_ENTRY* lpEntries;
- UINT* lpEntryCount;
- };
- #ifdef _AFXDLL
- #define DECLARE_EVENTSINK_MAP() \
- private: \
- static const AFX_EVENTSINKMAP_ENTRY _eventsinkEntries[]; \
- static UINT _eventsinkEntryCount; \
- protected: \
- static AFX_DATA const AFX_EVENTSINKMAP eventsinkMap; \
- static const AFX_EVENTSINKMAP* PASCAL _GetBaseEventSinkMap(); \
- virtual const AFX_EVENTSINKMAP* GetEventSinkMap() const; \
- #else
- #define DECLARE_EVENTSINK_MAP() \
- private: \
- static const AFX_EVENTSINKMAP_ENTRY _eventsinkEntries[]; \
- static UINT _eventsinkEntryCount; \
- protected: \
- static AFX_DATA const AFX_EVENTSINKMAP eventsinkMap; \
- virtual const AFX_EVENTSINKMAP* GetEventSinkMap() const; \
- #endif
- //#endif //!_AFX_NO_OCC_SUPPORT
- /////////////////////////////////////////////////////////////////////////////
- // OLE connection map handling (more in AFXDISP.H)
- #ifndef _AFX_NO_OLE_SUPPORT
- struct AFX_CONNECTIONMAP_ENTRY
- {
- const void* piid; // the interface id (IID)
- size_t nOffset; // offset of the interface vtable from m_unknown
- };
- struct AFX_CONNECTIONMAP
- {
- #ifdef _AFXDLL
- const AFX_CONNECTIONMAP* (PASCAL* pfnGetBaseMap)(); // NULL is root class
- #else
- const AFX_CONNECTIONMAP* pBaseMap;
- #endif
- const AFX_CONNECTIONMAP_ENTRY* pEntry; // map for this class
- };
- #ifdef _AFXDLL
- #define DECLARE_CONNECTION_MAP() \
- private: \
- static const AFX_CONNECTIONMAP_ENTRY _connectionEntries[]; \
- protected: \
- static AFX_DATA const AFX_CONNECTIONMAP connectionMap; \
- static const AFX_CONNECTIONMAP* PASCAL _GetBaseConnectionMap(); \
- virtual const AFX_CONNECTIONMAP* GetConnectionMap() const; \
- #else
- #define DECLARE_CONNECTION_MAP() \
- private: \
- static const AFX_CONNECTIONMAP_ENTRY _connectionEntries[]; \
- protected: \
- static AFX_DATA const AFX_CONNECTIONMAP connectionMap; \
- virtual const AFX_CONNECTIONMAP* GetConnectionMap() const; \
- #endif
- #endif //!_AFX_NO_OLE_SUPPORT
- /////////////////////////////////////////////////////////////////////////////
- // CCmdTarget proper
- #ifndef _AFX_NO_OCC_SUPPORT
- class COccManager; // forward reference (see ..\src\occimpl.h)
- #endif
- #ifdef _AFXDLL
- class CCmdTarget : public CObject
- #else
- class AFX_NOVTABLE CCmdTarget : public CObject
- #endif
- {
- DECLARE_DYNAMIC(CCmdTarget)
- protected:
- public:
- // Constructors
- CCmdTarget();
- // Attributes
- LPDISPATCH GetIDispatch(BOOL bAddRef);
- // retrieve IDispatch part of CCmdTarget
- static CCmdTarget* PASCAL FromIDispatch(LPDISPATCH lpDispatch);
- // map LPDISPATCH back to CCmdTarget* (inverse of GetIDispatch)
- BOOL IsResultExpected();
- // returns TRUE if automation function should return a value
- // Operations
- void EnableAutomation();
- // call in constructor to wire up IDispatch
- void EnableConnections();
- // call in constructor to wire up IConnectionPointContainer
- void BeginWaitCursor();
- void EndWaitCursor();
- void RestoreWaitCursor(); // call after messagebox
- #ifndef _AFX_NO_OLE_SUPPORT
- // dispatch OLE verbs through the message map
- BOOL EnumOleVerbs(LPENUMOLEVERB* ppenumOleVerb);
- BOOL DoOleVerb(LONG iVerb, LPMSG lpMsg, HWND hWndParent, LPCRECT lpRect);
- #endif
- // Overridables
- // route and dispatch standard command message types
- // (more sophisticated than OnCommand)
- virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra,
- AFX_CMDHANDLERINFO* pHandlerInfo);
- #ifndef _AFX_NO_OLE_SUPPORT
- // called when last OLE reference is released
- virtual void OnFinalRelease();
- #endif
- #ifndef _AFX_NO_OLE_SUPPORT
- // called before dispatching to an automation handler function
- virtual BOOL IsInvokeAllowed(DISPID dispid);
- #endif
- #ifndef _AFX_NO_OLE_SUPPORT
- // support for OLE type libraries
- void EnableTypeLib();
- HRESULT GetTypeInfoOfGuid(LCID lcid, const GUID& guid,
- LPTYPEINFO* ppTypeInfo);
- virtual BOOL GetDispatchIID(IID* pIID);
- virtual UINT GetTypeInfoCount();
- virtual CTypeLibCache* GetTypeLibCache();
- virtual HRESULT GetTypeLib(LCID lcid, LPTYPELIB* ppTypeLib);
- #endif
- // Implementation
- public:
- virtual ~CCmdTarget();
- #ifdef _DEBUG
- virtual void Dump(CDumpContext& dc) const;
- virtual void AssertValid() const;
- #endif
- #ifndef _AFX_NO_OLE_SUPPORT
- void GetNotSupported();
- void SetNotSupported();
- #endif
- protected:
- friend class CView;
- CView* GetRoutingView();
- CFrameWnd* GetRoutingFrame();
- static CView* PASCAL GetRoutingView_();
- static CFrameWnd* PASCAL GetRoutingFrame_();
- DECLARE_MESSAGE_MAP() // base class - no {{ }} macros
- #ifndef _AFX_NO_DOCOBJECT_SUPPORT
- DECLARE_OLECMD_MAP()
- friend class COleCmdUI;
- #endif
- #ifndef _AFX_NO_OLE_SUPPORT
- DECLARE_DISPATCH_MAP()
- DECLARE_CONNECTION_MAP()
- DECLARE_INTERFACE_MAP()
- #ifndef _AFX_NO_OCC_SUPPORT
- DECLARE_EVENTSINK_MAP()
- #endif // !_AFX_NO_OCC_SUPPORT
- // OLE interface map implementation
- public:
- // data used when CCmdTarget is made OLE aware
- long m_dwRef;
- LPUNKNOWN m_pOuterUnknown; // external controlling unknown if != NULL
- DWORD m_xInnerUnknown; // place-holder for inner controlling unknown
- public:
- // advanced operations
- void EnableAggregation(); // call to enable aggregation
- void ExternalDisconnect(); // forcibly disconnect
- LPUNKNOWN GetControllingUnknown();
- // get controlling IUnknown for aggregate creation
- // these versions do not delegate to m_pOuterUnknown
- DWORD InternalQueryInterface(const void*, LPVOID* ppvObj);
- DWORD InternalAddRef();
- DWORD InternalRelease();
- // these versions delegate to m_pOuterUnknown
- DWORD ExternalQueryInterface(const void*, LPVOID* ppvObj);
- DWORD ExternalAddRef();
- DWORD ExternalRelease();
- // implementation helpers
- LPUNKNOWN GetInterface(const void*);
- LPUNKNOWN QueryAggregates(const void*);
- // advanced overrideables for implementation
- virtual BOOL OnCreateAggregates();
- virtual LPUNKNOWN GetInterfaceHook(const void*);
- // OLE automation implementation
- protected:
- struct XDispatch
- {
- DWORD m_vtbl; // place-holder for IDispatch vtable
- #ifndef _AFX_NO_NESTED_DERIVATION
- size_t m_nOffset;
- #endif
- } m_xDispatch;
- BOOL m_bResultExpected;
- // member variable-based properties
- void GetStandardProp(const AFX_DISPMAP_ENTRY* pEntry,
- VARIANT* pvarResult, UINT* puArgErr);
- SCODE SetStandardProp(const AFX_DISPMAP_ENTRY* pEntry,
- DISPPARAMS* pDispParams, UINT* puArgErr);
- // DISPID to dispatch map lookup
- static UINT PASCAL GetEntryCount(const AFX_DISPMAP* pDispMap);
- const AFX_DISPMAP_ENTRY* PASCAL GetDispEntry(LONG memid);
- static LONG PASCAL MemberIDFromName(const AFX_DISPMAP* pDispMap, LPCTSTR lpszName);
- // helpers for member function calling implementation
- static UINT PASCAL GetStackSize(const BYTE* pbParams, VARTYPE vtResult);
- #ifdef _PPC_
- SCODE PushStackArgs(BYTE* pStack, const BYTE* pbParams,
- void* pResult, VARTYPE vtResult, DISPPARAMS* pDispParams,
- UINT* puArgErr, VARIANT* rgTempVars, UINT nSizeArgs);
- #else
- SCODE PushStackArgs(BYTE* pStack, const BYTE* pbParams,
- void* pResult, VARTYPE vtResult, DISPPARAMS* pDispParams,
- UINT* puArgErr, VARIANT* rgTempVars);
- #endif
- SCODE CallMemberFunc(const AFX_DISPMAP_ENTRY* pEntry, WORD wFlags,
- VARIANT* pvarResult, DISPPARAMS* pDispParams, UINT* puArgErr);
- friend class COleDispatchImpl;
- #ifndef _AFX_NO_OCC_SUPPORT
- public:
- // OLE event sink implementation
- BOOL OnEvent(UINT idCtrl, AFX_EVENT* pEvent,
- AFX_CMDHANDLERINFO* pHandlerInfo);
- protected:
- const AFX_EVENTSINKMAP_ENTRY* PASCAL GetEventSinkEntry(UINT idCtrl,
- AFX_EVENT* pEvent);
- #endif // !_AFX_NO_OCC_SUPPORT
- // OLE connection implementation
- struct XConnPtContainer
- {
- DWORD m_vtbl; // place-holder for IConnectionPointContainer vtable
- #ifndef _AFX_NO_NESTED_DERIVATION
- size_t m_nOffset;
- #endif
- } m_xConnPtContainer;
- #ifdef _AFXDLL
- AFX_MODULE_STATE* m_pModuleState;
- friend class CInnerUnknown;
- friend UINT APIENTRY _AfxThreadEntry(void* pParam);
- #endif
- virtual BOOL GetExtraConnectionPoints(CPtrArray* pConnPoints);
- virtual LPCONNECTIONPOINT GetConnectionHook(const IID& iid);
- friend class COleConnPtContainer;
- #endif //!_AFX_NO_OLE_SUPPORT
- };
- class CCmdUI // simple helper class
- {
- public:
- // Attributes
- UINT m_nID;
- UINT m_nIndex; // menu item or other index
- // if a menu item
- CMenu* m_pMenu; // NULL if not a menu
- CMenu* m_pSubMenu; // sub containing menu item
- // if a popup sub menu - ID is for first in popup
- // if from some other window
- CWnd* m_pOther; // NULL if a menu or not a CWnd
- // Operations to do in ON_UPDATE_COMMAND_UI
- virtual void Enable(BOOL bOn = TRUE);
- virtual void SetCheck(int nCheck = 1); // 0, 1 or 2 (indeterminate)
- virtual void SetRadio(BOOL bOn = TRUE);
- virtual void SetText(LPCTSTR lpszText);
- // Advanced operation
- void ContinueRouting();
- // Implementation
- CCmdUI();
- BOOL m_bEnableChanged;
- BOOL m_bContinueRouting;
- UINT m_nIndexMax; // last + 1 for iterating m_nIndex
- CMenu* m_pParentMenu; // NULL if parent menu not easily determined
- // (probably a secondary popup menu)
- BOOL DoUpdate(CCmdTarget* pTarget, BOOL bDisableIfNoHndler);
- };
- // special CCmdUI derived classes are used for other UI paradigms
- // like toolbar buttons and status indicators
- // pointer to afx_msg member function
- #ifndef AFX_MSG_CALL
- #define AFX_MSG_CALL
- #endif
- typedef void (AFX_MSG_CALL CCmdTarget::*AFX_PMSG)(void);
- enum AFX_DISPMAP_FLAGS
- {
- afxDispCustom = 0,
- afxDispStock = 1
- };
- struct AFX_DISPMAP_ENTRY
- {
- LPCTSTR lpszName; // member/property name
- long lDispID; // DISPID (may be DISPID_UNKNOWN)
- LPCSTR lpszParams; // member parameter description
- WORD vt; // return value type / or type of property
- AFX_PMSG pfn; // normal member On<membercall> or, OnGet<property>
- AFX_PMSG pfnSet; // special member for OnSet<property>
- size_t nPropOffset; // property offset
- AFX_DISPMAP_FLAGS flags;// flags (e.g. stock/custom)
- };
- struct AFX_EVENTSINKMAP_ENTRY
- {
- AFX_DISPMAP_ENTRY dispEntry;
- UINT nCtrlIDFirst;
- UINT nCtrlIDLast;
- };
- // DSC Sink state/reason codes passed to MFC user event handlers
- enum DSCSTATE
- {
- dscNoState = 0,
- dscOKToDo,
- dscCancelled,
- dscSyncBefore,
- dscAboutToDo,
- dscFailedToDo,
- dscSyncAfter,
- dscDidEvent
- };
- enum DSCREASON
- {
- dscNoReason = 0,
- dscClose,
- dscCommit,
- dscDelete,
- dscEdit,
- dscInsert,
- dscModify,
- dscMove
- };
- /////////////////////////////////////////////////////////////////////////////
- // CWnd implementation
- // structures (see afxext.h)
- struct CCreateContext; // context for creating things
- struct CPrintInfo; // print preview customization info
- struct AFX_MSGMAP_ENTRY
- {
- UINT nMessage; // windows message
- UINT nCode; // control code or WM_NOTIFY code
- UINT nID; // control ID (or 0 for windows messages)
- UINT nLastID; // used for entries specifying a range of control id's
- UINT nSig; // signature type (action) or pointer to message #
- AFX_PMSG pfn; // routine to call (or special value)
- };
- /////////////////////////////////////////////////////////////////////////////
- // CWnd - a Microsoft Windows application window
- class COleDropTarget; // for more information see AFXOLE.H
- class COleControlContainer;
- class COleControlSite;
- // CWnd::m_nFlags (generic to CWnd)
- #define WF_TOOLTIPS 0x0001 // window is enabled for tooltips
- #define WF_TEMPHIDE 0x0002 // window is temporarily hidden
- #define WF_STAYDISABLED 0x0004 // window should stay disabled
- #define WF_MODALLOOP 0x0008 // currently in modal loop
- #define WF_CONTINUEMODAL 0x0010 // modal loop should continue running
- #define WF_OLECTLCONTAINER 0x0100 // some descendant is an OLE control
- #define WF_TRACKINGTOOLTIPS 0x0400 // window is enabled for tracking tooltips
- // CWnd::m_nFlags (specific to CFrameWnd)
- #define WF_STAYACTIVE 0x0020 // look active even though not active
- #define WF_NOPOPMSG 0x0040 // ignore WM_POPMESSAGESTRING calls
- #define WF_MODALDISABLE 0x0080 // window is disabled
- #define WF_KEEPMINIACTIVE 0x0200 // stay activate even though you are deactivated
- // flags for CWnd::RunModalLoop
- #define MLF_NOIDLEMSG 0x0001 // don't send WM_ENTERIDLE messages
- #define MLF_NOKICKIDLE 0x0002 // don't send WM_KICKIDLE messages
- #define MLF_SHOWONIDLE 0x0004 // show window if not visible at idle time
- // extra MFC defined TTF_ flags for TOOLINFO::uFlags
- #define TTF_NOTBUTTON 0x80000000L // no status help on buttondown
- #define TTF_ALWAYSTIP 0x40000000L // always show the tip even if not active
- class CWnd : public CCmdTarget
- {
- DECLARE_DYNCREATE(CWnd)
- protected:
- static const MSG* PASCAL GetCurrentMessage();
- // Attributes
- public:
- HWND m_hWnd; // must be first data member
- operator HWND() const;
- BOOL operator==(const CWnd& wnd) const;
- BOOL operator!=(const CWnd& wnd) const;
- HWND GetSafeHwnd() const;
- DWORD GetStyle() const;
- DWORD GetExStyle() const;
- BOOL ModifyStyle(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0);
- BOOL ModifyStyleEx(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0);
- CWnd* GetOwner() const;
- void SetOwner(CWnd* pOwnerWnd);
- // Constructors and other creation
- CWnd();
- static CWnd* PASCAL FromHandle(HWND hWnd);
- static CWnd* PASCAL FromHandlePermanent(HWND hWnd);
- static void PASCAL DeleteTempMap();
- BOOL Attach(HWND hWndNew);
- HWND Detach();
- // subclassing/unsubclassing functions
- virtual void PreSubclassWindow();
- BOOL SubclassWindow(HWND hWnd);
- BOOL SubclassDlgItem(UINT nID, CWnd* pParent);
- HWND UnsubclassWindow();
- // handling of RT_DLGINIT resource (extension to RT_DIALOG)
- BOOL ExecuteDlgInit(LPCTSTR lpszResourceName);
- BOOL ExecuteDlgInit(LPVOID lpResource);
- public:
- // for child windows, views, panes etc
- virtual BOOL Create(LPCTSTR lpszClassName,
- LPCTSTR lpszWindowName, DWORD dwStyle,
- const RECT& rect,
- CWnd* pParentWnd, UINT nID,
- CCreateContext* pContext = NULL);
- // advanced creation (allows access to extended styles)
- BOOL CreateEx(DWORD dwExStyle, LPCTSTR lpszClassName,
- LPCTSTR lpszWindowName, DWORD dwStyle,
- int x, int y, int nWidth, int nHeight,
- HWND hWndParent, HMENU nIDorHMenu, LPVOID lpParam = NULL);
- BOOL CreateEx(DWORD dwExStyle, LPCTSTR lpszClassName,
- LPCTSTR lpszWindowName, DWORD dwStyle,
- const RECT& rect,
- CWnd* pParentWnd, UINT nID,
- LPVOID lpParam = NULL);
- #ifndef _AFX_NO_OCC_SUPPORT
- // for wrapping OLE controls
- BOOL CreateControl(REFCLSID clsid, LPCTSTR pszWindowName, DWORD dwStyle,
- const RECT& rect, CWnd* pParentWnd, UINT nID, CFile* pPersist=NULL,
- BOOL bStorage=FALSE, BSTR bstrLicKey=NULL);
- BOOL CreateControl(LPCTSTR pszClass, LPCTSTR pszWindowName, DWORD dwStyle,
- const RECT& rect, CWnd* pParentWnd, UINT nID, CFile* pPersist=NULL,
- BOOL bStorage=FALSE, BSTR bstrLicKey=NULL);
- // Another overload for creating controls that use default extents.
- BOOL CreateControl( REFCLSID clsid, LPCTSTR pszWindowName, DWORD dwStyle,
- const POINT* ppt, const SIZE* psize, CWnd* pParentWnd, UINT nID,
- CFile* pPersist = NULL, BOOL bStorage = FALSE, BSTR bstrLicKey = NULL );
- LPUNKNOWN GetControlUnknown();
- #endif
- virtual BOOL DestroyWindow();
- // special pre-creation and window rect adjustment hooks
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- // Advanced: virtual AdjustWindowRect
- enum AdjustType { adjustBorder = 0, adjustOutside = 1 };
- virtual void CalcWindowRect(LPRECT lpClientRect,
- UINT nAdjustType = adjustBorder);
- // Window tree access
- int GetDlgCtrlID() const;
- int SetDlgCtrlID(int nID);
- // get and set window ID, for child windows only
- CWnd* GetDlgItem(int nID) const;
- // get immediate child with given ID
- void GetDlgItem(int nID, HWND* phWnd) const;
- // as above, but returns HWND
- CWnd* GetDescendantWindow(int nID, BOOL bOnlyPerm = FALSE) const;
- // like GetDlgItem but recursive
- void SendMessageToDescendants(UINT message, WPARAM wParam = 0,
- LPARAM lParam = 0, BOOL bDeep = TRUE, BOOL bOnlyPerm = FALSE);
- CFrameWnd* GetParentFrame() const;
- CWnd* GetTopLevelParent() const;
- CWnd* GetTopLevelOwner() const;
- CWnd* GetParentOwner() const;
- CFrameWnd* GetTopLevelFrame() const;
- static CWnd* PASCAL GetSafeOwner(CWnd* pParent = NULL, HWND* pWndTop = NULL);
- // Message Functions
- LRESULT SendMessage(UINT message, WPARAM wParam = 0, LPARAM lParam = 0);
- BOOL PostMessage(UINT message, WPARAM wParam = 0, LPARAM lParam = 0);
- BOOL SendNotifyMessage(UINT message, WPARAM wParam, LPARAM lParam);
- BOOL SendChildNotifyLastMsg(LRESULT* pResult = NULL);
- // Message processing for modeless dialog-like windows
- BOOL IsDialogMessage(LPMSG lpMsg);
- // Window Text Functions
- void SetWindowText(LPCTSTR lpszString);
- int GetWindowText(LPTSTR lpszStringBuf, int nMaxCount) const;
- void GetWindowText(CString& rString) const;
- int GetWindowTextLength() const;
- void SetFont(CFont* pFont, BOOL bRedraw = TRUE);
- CFont* GetFont() const;
- // CMenu Functions - non-Child windows only
- CMenu* GetMenu() const;
- BOOL SetMenu(CMenu* pMenu);
- void DrawMenuBar();
- CMenu* GetSystemMenu(BOOL bRevert) const;
- BOOL HiliteMenuItem(CMenu* pMenu, UINT nIDHiliteItem, UINT nHilite);
- // Window Size and Position Functions
- BOOL IsIconic() const;
- BOOL IsZoomed() const;
- void MoveWindow(int x, int y, int nWidth, int nHeight,
- BOOL bRepaint = TRUE);
- void MoveWindow(LPCRECT lpRect, BOOL bRepaint = TRUE);
- int SetWindowRgn(HRGN hRgn, BOOL bRedraw);
- int GetWindowRgn(HRGN hRgn) const;
- static AFX_DATA const CWnd wndTop; // SetWindowPos's pWndInsertAfter
- static AFX_DATA const CWnd wndBottom; // SetWindowPos's pWndInsertAfter
- static AFX_DATA const CWnd wndTopMost; // SetWindowPos pWndInsertAfter
- static AFX_DATA const CWnd wndNoTopMost; // SetWindowPos pWndInsertAfter
- BOOL SetWindowPos(const CWnd* pWndInsertAfter, int x, int y,
- int cx, int cy, UINT nFlags);
- UINT ArrangeIconicWindows();
- void BringWindowToTop();
- void GetWindowRect(LPRECT lpRect) const;
- void GetClientRect(LPRECT lpRect) const;
- BOOL GetWindowPlacement(WINDOWPLACEMENT* lpwndpl) const;
- BOOL SetWindowPlacement(const WINDOWPLACEMENT* lpwndpl);
- // Coordinate Mapping Functions
- void ClientToScreen(LPPOINT lpPoint) const;
- void ClientToScreen(LPRECT lpRect) const;
- void ScreenToClient(LPPOINT lpPoint) const;
- void ScreenToClient(LPRECT lpRect) const;
- void MapWindowPoints(CWnd* pwndTo, LPPOINT lpPoint, UINT nCount) const;
- void MapWindowPoints(CWnd* pwndTo, LPRECT lpRect) const;
- // Update/Painting Functions
- CDC* BeginPaint(LPPAINTSTRUCT lpPaint);
- void EndPaint(LPPAINTSTRUCT lpPaint);
- CDC* GetDC();
- CDC* GetWindowDC();
- int ReleaseDC(CDC* pDC);
- void Print(CDC* pDC, DWORD dwFlags) const;
- void PrintClient(CDC* pDC, DWORD dwFlags) const;
- void UpdateWindow();
- void SetRedraw(BOOL bRedraw = TRUE);
- BOOL GetUpdateRect(LPRECT lpRect, BOOL bErase = FALSE);
- int GetUpdateRgn(CRgn* pRgn, BOOL bErase = FALSE);
- void Invalidate(BOOL bErase = TRUE);
- void InvalidateRect(LPCRECT lpRect, BOOL bErase = TRUE);
- void InvalidateRgn(CRgn* pRgn, BOOL bErase = TRUE);
- void ValidateRect(LPCRECT lpRect);
- void ValidateRgn(CRgn* pRgn);
- BOOL ShowWindow(int nCmdShow);
- BOOL IsWindowVisible() const;
- void ShowOwnedPopups(BOOL bShow = TRUE);
- CDC* GetDCEx(CRgn* prgnClip, DWORD flags);
- BOOL LockWindowUpdate(); // for backward compatibility
- void UnlockWindowUpdate();
- BOOL RedrawWindow(LPCRECT lpRectUpdate = NULL,
- CRgn* prgnUpdate = NULL,
- UINT flags = RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE);
- BOOL EnableScrollBar(int nSBFlags, UINT nArrowFlags = ESB_ENABLE_BOTH);
- // Timer Functions
- UINT SetTimer(UINT nIDEvent, UINT nElapse,
- void (CALLBACK* lpfnTimer)(HWND, UINT, UINT, DWORD));
- BOOL KillTimer(int nIDEvent);
- // ToolTip Functions
- BOOL EnableToolTips(BOOL bEnable = TRUE);
- BOOL EnableTrackingToolTips(BOOL bEnable = TRUE);
- static void PASCAL CancelToolTips(BOOL bKeys = FALSE);
- void FilterToolTipMessage(MSG* pMsg);
- // for command hit testing (used for automatic tooltips)
- virtual int OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
- // Window State Functions
- BOOL IsWindowEnabled() const;
- BOOL EnableWindow(BOOL bEnable = TRUE);
- // the active window applies only to top-level (frame windows)
- static CWnd* PASCAL GetActiveWindow();
- CWnd* SetActiveWindow();
- // the foreground window applies only to top-level windows (frame windows)
- BOOL SetForegroundWindow();
- static CWnd* PASCAL GetForegroundWindow();
- // capture and focus apply to all windows
- static CWnd* PASCAL GetCapture();
- CWnd* SetCapture();
- static CWnd* PASCAL GetFocus();
- CWnd* SetFocus();
- static CWnd* PASCAL GetDesktopWindow();
- // Obsolete and non-portable APIs - not recommended for new code
- void CloseWindow();
- BOOL OpenIcon();
- // Dialog-Box Item Functions
- // (NOTE: Dialog-Box Items/Controls are not necessarily in dialog boxes!)
- void CheckDlgButton(int nIDButton, UINT nCheck);
- void CheckRadioButton(int nIDFirstButton, int nIDLastButton,
- int nIDCheckButton);
- int GetCheckedRadioButton(int nIDFirstButton, int nIDLastButton);
- int DlgDirList(LPTSTR lpPathSpec, int nIDListBox,
- int nIDStaticPath, UINT nFileType);
- int DlgDirListComboBox(LPTSTR lpPathSpec, int nIDComboBox,
- int nIDStaticPath, UINT nFileType);
- BOOL DlgDirSelect(LPTSTR lpString, int nIDListBox);
- BOOL DlgDirSelectComboBox(LPTSTR lpString, int nIDComboBox);
- UINT GetDlgItemInt(int nID, BOOL* lpTrans = NULL,
- BOOL bSigned = TRUE) const;
- int GetDlgItemText(int nID, LPTSTR lpStr, int nMaxCount) const;
- int GetDlgItemText(int nID, CString& rString) const;
- CWnd* GetNextDlgGroupItem(CWnd* pWndCtl, BOOL bPrevious = FALSE) const;
- CWnd* GetNextDlgTabItem(CWnd* pWndCtl, BOOL bPrevious = FALSE) const;
- UINT IsDlgButtonChecked(int nIDButton) const;
- LRESULT SendDlgItemMessage(int nID, UINT message,
- WPARAM wParam = 0, LPARAM lParam = 0);
- void SetDlgItemInt(int nID, UINT nValue, BOOL bSigned = TRUE);
- void SetDlgItemText(int nID, LPCTSTR lpszString);
- // Scrolling Functions
- int GetScrollPos(int nBar) const;
- void GetScrollRange(int nBar, LPINT lpMinPos, LPINT lpMaxPos) const;
- void ScrollWindow(int xAmount, int yAmount,
- LPCRECT lpRect = NULL,
- LPCRECT lpClipRect = NULL);
- int SetScrollPos(int nBar, int nPos, BOOL bRedraw = TRUE);
- void SetScrollRange(int nBar, int nMinPos, int nMaxPos,
- BOOL bRedraw = TRUE);
- void ShowScrollBar(UINT nBar, BOOL bShow = TRUE);
- void EnableScrollBarCtrl(int nBar, BOOL bEnable = TRUE);
- virtual CScrollBar* GetScrollBarCtrl(int nBar) const;
- // return sibling scrollbar control (or NULL if none)
- int ScrollWindowEx(int dx, int dy,
- LPCRECT lpRectScroll, LPCRECT lpRectClip,
- CRgn* prgnUpdate, LPRECT lpRectUpdate, UINT flags);
- BOOL SetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo,
- BOOL bRedraw = TRUE);
- BOOL GetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo, UINT nMask = SIF_ALL);
- int GetScrollLimit(int nBar);
- // Window Access Functions
- CWnd* ChildWindowFromPoint(POINT point) const;
- CWnd* ChildWindowFromPoint(POINT point, UINT nFlags) const;
- static CWnd* PASCAL FindWindow(LPCTSTR lpszClassName, LPCTSTR lpszWindowName);
- CWnd* GetNextWindow(UINT nFlag = GW_HWNDNEXT) const;
- CWnd* GetTopWindow() const;
- CWnd* GetWindow(UINT nCmd) const;
- CWnd* GetLastActivePopup() const;
- BOOL IsChild(const CWnd* pWnd) const;
- CWnd* GetParent() const;
- CWnd* SetParent(CWnd* pWndNewParent);
- static CWnd* PASCAL WindowFromPoint(POINT point);
- // Alert Functions
- BOOL FlashWindow(BOOL bInvert);
- int MessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption = NULL,
- UINT nType = MB_OK);
- // Clipboard Functions
- BOOL ChangeClipboardChain(HWND hWndNext);
- HWND SetClipboardViewer();
- BOOL OpenClipboard();
- static CWnd* PASCAL GetClipboardOwner();
- static CWnd* PASCAL GetClipboardViewer();
- static CWnd* PASCAL GetOpenClipboardWindow();
- // Caret Functions
- void CreateCaret(CBitmap* pBitmap);
- void CreateSolidCaret(int nWidth, int nHeight);
- void CreateGrayCaret(int nWidth, int nHeight);
- static CPoint PASCAL GetCaretPos();
- static void PASCAL SetCaretPos(POINT point);
- void HideCaret();
- void ShowCaret();
- // Shell Interaction Functions
- void DragAcceptFiles(BOOL bAccept = TRUE);
- // Icon Functions
- HICON SetIcon(HICON hIcon, BOOL bBigIcon);
- HICON GetIcon(BOOL bBigIcon) const;
- // Context Help Functions
- BOOL SetWindowContextHelpId(DWORD dwContextHelpId);
- DWORD GetWindowContextHelpId() const;
- // Dialog Data support
- public:
- BOOL UpdateData(BOOL bSaveAndValidate = TRUE);
- // data wnd must be same type as this
- // Help Command Handlers
- afx_msg void OnHelp(); // F1 (uses current context)
- afx_msg void OnHelpIndex(); // ID_HELP_INDEX
- afx_msg void OnHelpFinder(); // ID_HELP_FINDER, ID_DEFAULT_HELP
- afx_msg void OnHelpUsing(); // ID_HELP_USING
- virtual void WinHelp(DWORD dwData, UINT nCmd = HELP_CONTEXT);
- // Layout and other functions
- public:
- enum RepositionFlags
- { reposDefault = 0, reposQuery = 1, reposExtra = 2 };
- void RepositionBars(UINT nIDFirst, UINT nIDLast, UINT nIDLeftOver,
- UINT nFlag = reposDefault, LPRECT lpRectParam = NULL,
- LPCRECT lpRectClient = NULL, BOOL bStretch = TRUE);
- // dialog support
- void UpdateDialogControls(CCmdTarget* pTarget, BOOL bDisableIfNoHndler);
- void CenterWindow(CWnd* pAlternateOwner = NULL);
- int RunModalLoop(DWORD dwFlags = 0);
- virtual BOOL ContinueModal();
- virtual void EndModalLoop(int nResult);
- #ifndef _AFX_NO_OCC_SUPPORT
- // OLE control wrapper functions
- void AFX_CDECL InvokeHelper(DISPID dwDispID, WORD wFlags,
- VARTYPE vtRet, void* pvRet, const BYTE* pbParamInfo, ...);
- void AFX_CDECL SetProperty(DISPID dwDispID, VARTYPE vtProp, ...);
- void GetProperty(DISPID dwDispID, VARTYPE vtProp, void* pvProp) const;
- IUnknown* GetDSCCursor();
- void BindDefaultProperty(DISPID dwDispID, VARTYPE vtProp, LPCTSTR szFieldName, CWnd* pDSCWnd);
- void BindProperty(DISPID dwDispId, CWnd* pWndDSC);
- #endif
- // Window-Management message handler member functions
- protected:
- virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
- virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
- afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
- afx_msg void OnActivateApp(BOOL bActive, HTASK hTask);
- afx_msg LRESULT OnActivateTopLevel(WPARAM, LPARAM);
- afx_msg void OnCancelMode();
- afx_msg void OnChildActivate();
- afx_msg void OnClose();
- afx_msg void OnContextMenu(CWnd* pWnd, CPoint pos);
- afx_msg BOOL OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct);
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
- afx_msg void OnDestroy();
- afx_msg void OnEnable(BOOL bEnable);
- afx_msg void OnEndSession(BOOL bEnding);
- afx_msg void OnEnterIdle(UINT nWhy, CWnd* pWho);
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
- afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
- afx_msg void OnIconEraseBkgnd(CDC* pDC);
- afx_msg void OnKillFocus(CWnd* pNewWnd);
- afx_msg LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu);
- afx_msg void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu);
- afx_msg void OnMove(int x, int y);
- afx_msg void OnPaint();
- afx_msg void OnParentNotify(UINT message, LPARAM lParam);
- afx_msg HCURSOR OnQueryDragIcon();
- afx_msg BOOL OnQueryEndSession();
- afx_msg BOOL OnQueryNewPalette();
- afx_msg BOOL OnQueryOpen();
- afx_msg void OnSetFocus(CWnd* pOldWnd);
- afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnTCard(UINT idAction, DWORD dwActionData);
- afx_msg void OnWindowPosChanging(WINDOWPOS* lpwndpos);
- afx_msg void OnWindowPosChanged(WINDOWPOS* lpwndpos);
- // Nonclient-Area message handler member functions
- afx_msg BOOL OnNcActivate(BOOL bActive);
- afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp);
- afx_msg BOOL OnNcCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg void OnNcDestroy();
- afx_msg UINT OnNcHitTest(CPoint point);
- afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point);
- afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
- afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
- afx_msg void OnNcMButtonDblClk(UINT nHitTest, CPoint point);
- afx_msg void OnNcMButtonDown(UINT nHitTest, CPoint point);
- afx_msg void OnNcMButtonUp(UINT nHitTest, CPoint point);
- afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point);
- afx_msg void OnNcPaint();
- afx_msg void OnNcRButtonDblClk(UINT nHitTest, CPoint point);
- afx_msg void OnNcRButtonDown(UINT nHitTest, CPoint point);
- afx_msg void OnNcRButtonUp(UINT nHitTest, CPoint point);
- // System message handler member functions
- afx_msg void OnDropFiles(HDROP hDropInfo);
- afx_msg void OnPaletteIsChanging(CWnd* pRealizeWnd);
- afx_msg void OnSysChar(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
- afx_msg void OnSysDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg void OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg void OnCompacting(UINT nCpuTime);
- afx_msg void OnDevModeChange(LPTSTR lpDeviceName);
- afx_msg void OnFontChange();
- afx_msg void OnPaletteChanged(CWnd* pFocusWnd);
- afx_msg void OnSpoolerStatus(UINT nStatus, UINT nJobs);
- afx_msg void OnSysColorChange();
- afx_msg void OnTimeChange();
- afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
- afx_msg void OnWinIniChange(LPCTSTR lpszSection);
- // Input message handler member functions
- afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg void OnDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
- afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
- afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
- afx_msg void OnMButtonDblClk(UINT nFlags, CPoint point);
- afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
- afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
- afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
- afx_msg LRESULT OnRegisteredMouseWheel(WPARAM wParam, LPARAM lParam);
- afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
- afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
- afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
- afx_msg void OnTimer(UINT nIDEvent);
- // Initialization message handler member functions
- afx_msg void OnInitMenu(CMenu* pMenu);
- afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
- // Clipboard message handler member functions
- afx_msg void OnAskCbFormatName(UINT nMaxCount, LPTSTR lpszString);
- afx_msg void OnChangeCbChain(HWND hWndRemove, HWND hWndAfter);
- afx_msg void OnDestroyClipboard();
- afx_msg void OnDrawClipboard();
- afx_msg void OnHScrollClipboard(CWnd* pClipAppWnd, UINT nSBCode, UINT nPos);
- afx_msg void OnPaintClipboard(CWnd* pClipAppWnd, HGLOBAL hPaintStruct);
- afx_msg void OnRenderAllFormats();
- afx_msg void OnRenderFormat(UINT nFormat);
- afx_msg void OnSizeClipboard(CWnd* pClipAppWnd, HGLOBAL hRect);
- afx_msg void OnVScrollClipboard(CWnd* pClipAppWnd, UINT nSBCode, UINT nPos);
- // Control message handler member functions
- afx_msg int OnCompareItem(int nIDCtl, LPCOMPAREITEMSTRUCT lpCompareItemStruct);
- afx_msg void OnDeleteItem(int nIDCtl, LPDELETEITEMSTRUCT lpDeleteItemStruct);
- afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
- afx_msg UINT OnGetDlgCode();
- afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
- afx_msg int OnCharToItem(UINT nChar, CListBox* pListBox, UINT nIndex);
- afx_msg int OnVKeyToItem(UINT nKey, CListBox* pListBox, UINT nIndex);
- // MDI message handler member functions
- afx_msg void OnMDIActivate(BOOL bActivate,
- CWnd* pActivateWnd, CWnd* pDeactivateWnd);
- // Menu loop notification messages
- afx_msg void OnEnterMenuLoop(BOOL bIsTrackPopupMenu);
- afx_msg void OnExitMenuLoop(BOOL bIsTrackPopupMenu);
- // Win4 messages
- afx_msg void OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct);
- afx_msg void OnStyleChanging(int nStyleType, LPSTYLESTRUCT lpStyleStruct);
- afx_msg void OnSizing(UINT nSide, LPRECT lpRect);
- afx_msg void OnMoving(UINT nSide, LPRECT lpRect);
- afx_msg void OnCaptureChanged(CWnd* pWnd);
- afx_msg BOOL OnDeviceChange(UINT nEventType, DWORD dwData);
- // Overridables and other helpers (for implementation of derived classes)
- protected:
- // for deriving from a standard control
- virtual WNDPROC* GetSuperWndProcAddr();
- // for dialog data exchange and validation
- virtual void DoDataExchange(CDataExchange* pDX);
- public:
- // for modality
- virtual void BeginModalState();
- virtual void EndModalState();
- // for translating Windows messages in main message pump
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- #ifndef _AFX_NO_OCC_SUPPORT
- // for ambient properties exposed to contained OLE controls
- virtual BOOL OnAmbientProperty(COleControlSite* pSite, DISPID dispid,
- VARIANT* pvar);
- #endif
- protected:
- // for processing Windows messages
- virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
- virtual BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
- // for handling default processing
- LRESULT Default();
- virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
- // for custom cleanup after WM_NCDESTROY
- virtual void PostNcDestroy();
- // for notifications from parent
- virtual BOOL OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
- // return TRUE if parent should not process this message
- BOOL ReflectChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
- static BOOL PASCAL ReflectLastMsg(HWND hWndChild, LRESULT* pResult = NULL);
- // Implementation
- public:
- virtual ~CWnd();
- virtual BOOL CheckAutoCenter();
- #ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
- #endif
- #ifndef _AFX_NO_CTL3D_SUPPORT
- // 3D support (these APIs will be obsolete with next version of Windows)
- BOOL SubclassCtl3d(int nControlType = -1);
- // see CTL3D.H for list of control types
- BOOL SubclassDlg3d(DWORD dwMask = 0xFFFF /*CTL3D_ALL*/);
- // see CTL3D.H for list of mask values
- #endif
- static BOOL PASCAL GrayCtlColor(HDC hDC, HWND hWnd, UINT nCtlColor,
- HBRUSH hbrGray, COLORREF clrText);
- #ifndef _AFX_NO_GRAYDLG_SUPPORT
- HBRUSH OnGrayCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
- #endif
- // helper routines for implementation
- BOOL HandleFloatingSysCommand(UINT nID, LPARAM lParam);
- BOOL IsTopParentActive() const;
- void ActivateTopParent();
- static BOOL PASCAL WalkPreTranslateTree(HWND hWndStop, MSG* pMsg);
- static CWnd* PASCAL GetDescendantWindow(HWND hWnd, int nID,
- BOOL bOnlyPerm);
- static void PASCAL SendMessageToDescendants(HWND hWnd, UINT message,
- WPARAM wParam, LPARAM lParam, BOOL bDeep, BOOL bOnlyPerm);
- virtual BOOL IsFrameWnd() const; // IsKindOf(RUNTIME_CLASS(CFrameWnd)))
- virtual void OnFinalRelease();
- BOOL PreTranslateInput(LPMSG lpMsg);
- static BOOL PASCAL ModifyStyle(HWND hWnd, DWORD dwRemove, DWORD dwAdd,
- UINT nFlags);
- static BOOL PASCAL ModifyStyleEx(HWND hWnd, DWORD dwRemove, DWORD dwAdd,
- UINT nFlags);
- static void PASCAL _FilterToolTipMessage(MSG* pMsg, CWnd* pWnd);
- BOOL _EnableToolTips(BOOL bEnable, UINT nFlag);
- static HWND PASCAL GetSafeOwner_(HWND hWnd, HWND* pWndTop);
- public:
- HWND m_hWndOwner; // implementation of SetOwner and GetOwner
- UINT m_nFlags; // see WF_ flags above
- protected:
- WNDPROC m_pfnSuper; // for subclassing of controls
- static const UINT m_nMsgDragList;
- int m_nModalResult; // for return values from CWnd::RunModalLoop
- COleDropTarget* m_pDropTarget; // for automatic cleanup of drop target
- friend class COleDropTarget;
- friend class CFrameWnd;
- // for creating dialogs and dialog-like windows
- BOOL CreateDlg(LPCTSTR lpszTemplateName, CWnd* pParentWnd);
- BOOL CreateDlgIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd);
- BOOL CreateDlgIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd,
- HINSTANCE hInst);
- #ifndef _AFX_NO_OCC_SUPPORT
- COleControlContainer* m_pCtrlCont; // for containing OLE controls
- COleControlSite* m_pCtrlSite; // for wrapping an OLE control
- friend class COccManager;
- friend class COleControlSite;
- friend class COleControlContainer;
- BOOL InitControlContainer();
- virtual BOOL SetOccDialogInfo(struct _AFX_OCC_DIALOG_INFO* pOccDialogInfo);
- void AttachControlSite(CHandleMap* pMap);
- public:
- void AttachControlSite(CWnd* pWndParent);
- #endif
- protected:
- // implementation of message dispatch/hooking
- friend LRESULT CALLBACK _AfxSendMsgHook(int, WPARAM, LPARAM);
- friend void AFXAPI _AfxStandardSubclass(HWND);
- friend LRESULT CALLBACK _AfxCbtFilterHook(int, WPARAM, LPARAM);
- friend LRESULT AFXAPI AfxCallWndProc(CWnd*, HWND, UINT, WPARAM, LPARAM);
- // standard message implementation
- afx_msg LRESULT OnNTCtlColor(WPARAM wParam, LPARAM lParam);
- #ifndef _AFX_NO_CTL3D_SUPPORT
- afx_msg LRESULT OnQuery3dControls(WPARAM, LPARAM);
- #endif
- afx_msg LRESULT OnDisplayChange(WPARAM, LPARAM);
- afx_msg LRESULT OnDragList(WPARAM, LPARAM);
- //{{AFX_MSG(CWnd)
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- private:
- CWnd(HWND hWnd); // just for special initialization
- };
- // helpers for registering your own WNDCLASSes
- LPCTSTR AFXAPI AfxRegisterWndClass(UINT nClassStyle,
- HCURSOR hCursor = 0, HBRUSH hbrBackground = 0, HICON hIcon = 0);
- BOOL AFXAPI AfxRegisterClass(WNDCLASS* lpWndClass);
- // helper to initialize rich edit control
- BOOL AFXAPI AfxInitRichEdit();
- // Implementation
- LRESULT CALLBACK AfxWndProc(HWND, UINT, WPARAM, LPARAM);
- WNDPROC AFXAPI AfxGetAfxWndProc();
- #define AfxWndProc (*AfxGetAfxWndProc())
- typedef void (AFX_MSG_CALL CWnd::*AFX_PMSGW)(void);
- // like 'AFX_PMSG' but for CWnd derived classes only
- typedef void (AFX_MSG_CALL CWinThread::*AFX_PMSGT)(void);
- // like 'AFX_PMSG' but for CWinThread-derived classes only
- /////////////////////////////////////////////////////////////////////////////
- // CDialog - a modal or modeless dialog
- class CDialog : public CWnd
- {
- DECLARE_DYNAMIC(CDialog)
- // Modeless construct
- public:
- CDialog();
- BOOL Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL);
- BOOL Create(UINT nIDTemplate, CWnd* pParentWnd = NULL);
- BOOL CreateIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd = NULL,
- void* lpDialogInit = NULL);
- BOOL CreateIndirect(HGLOBAL hDialogTemplate, CWnd* pParentWnd = NULL);
- // Modal construct
- public:
- CDialog(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL);
- CDialog(UINT nIDTemplate, CWnd* pParentWnd = NULL);
- BOOL InitModalIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd = NULL,
- void* lpDialogInit = NULL);
- BOOL InitModalIndirect(HGLOBAL hDialogTemplate, CWnd* pParentWnd = NULL);
- // Attributes
- public:
- void MapDialogRect(LPRECT lpRect) const;
- void SetHelpID(UINT nIDR);
- // Operations
- public:
- // modal processing
- virtual int DoModal();
- // support for passing on tab control - use 'PostMessage' if needed
- void NextDlgCtrl() const;
- void PrevDlgCtrl() const;
- void GotoDlgCtrl(CWnd* pWndCtrl);
- // default button access
- void SetDefID(UINT nID);
- DWORD GetDefID() const;
- // termination
- void EndDialog(int nResult);
- // Overridables (special message map entries)
- virtual BOOL OnInitDialog();
- virtual void OnSetFont(CFont* pFont);
- protected:
- virtual void OnOK();
- virtual void OnCancel();
- // Implementation
- public:
- virtual ~CDialog();
- #ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
- #endif
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra,
- AFX_CMDHANDLERINFO* pHandlerInfo);
- virtual BOOL CheckAutoCenter();
- protected:
- UINT m_nIDHelp; // Help ID (0 for none, see HID_BASE_RESOURCE)
- // parameters for 'DoModal'
- LPCTSTR m_lpszTemplateName; // name or MAKEINTRESOURCE
- HGLOBAL m_hDialogTemplate; // indirect (m_lpDialogTemplate == NULL)
- LPCDLGTEMPLATE m_lpDialogTemplate; // indirect if (m_lpszTemplateName == NULL)
- void* m_lpDialogInit; // DLGINIT resource data
- CWnd* m_pParentWnd; // parent/owner window
- HWND m_hWndTop; // top level parent window (may be disabled)
- #ifndef _AFX_NO_OCC_SUPPORT
- _AFX_OCC_DIALOG_INFO* m_pOccDialogInfo;
- virtual BOOL SetOccDialogInfo(_AFX_OCC_DIALOG_INFO* pOccDialogInfo);
- #endif
- virtual void PreInitDialog();
- // implementation helpers
- HWND PreModal();
- void PostModal();
- BOOL CreateIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd,
- void* lpDialogInit, HINSTANCE hInst);
- BOOL CreateIndirect(HGLOBAL hDialogTemplate, CWnd* pParentWnd,
- HINSTANCE hInst);
- protected:
- //{{AFX_MSG(CDialog)
- afx_msg LRESULT OnCommandHelp(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnHelpHitTest(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT HandleInitDialog(WPARAM, LPARAM);
- afx_msg LRESULT HandleSetFont(WPARAM, LPARAM);
- //}}AFX_MSG
- #ifndef _AFX_NO_GRAYDLG_SUPPORT
- afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
- #endif
- DECLARE_MESSAGE_MAP()
- };
- // all CModalDialog functionality is now in CDialog
- #define CModalDialog CDialog
- /////////////////////////////////////////////////////////////////////////////
- // Standard Windows controls
- class CStatic : public CWnd
- {
- DECLARE_DYNAMIC(CStatic)
- // Constructors
- public:
- CStatic();
- BOOL Create(LPCTSTR lpszText, DWORD dwStyle,
- const RECT& rect, CWnd* pParentWnd, UINT nID = 0xffff);
- // Operations
- HICON SetIcon(HICON hIcon);
- HICON GetIcon() const;
- #if (WINVER >= 0x400)
- HENHMETAFILE SetEnhMetaFile(HENHMETAFILE hMetaFile);
- HENHMETAFILE GetEnhMetaFile() const;
- HBITMAP SetBitmap(HBITMAP hBitmap);
- HBITMAP GetBitmap() const;
- HCURSOR SetCursor(HCURSOR hCursor);
- HCURSOR GetCursor();
- #endif
- // Implementation
- public:
- virtual ~CStatic();
- };
- class CButton : public CWnd
- {
- DECLARE_DYNAMIC(CButton)
- // Constructors
- public:
- CButton();
- BOOL Create(LPCTSTR lpszCaption, DWORD dwStyle,
- const RECT& rect, CWnd* pParentWnd, UINT nID);
- // Attributes
- UINT GetState() const;
- void SetState(BOOL bHighlight);
- int GetCheck() const;
- void SetCheck(int nCheck);
- UINT GetButtonStyle() const;
- void SetButtonStyle(UINT nStyle, BOOL bRedraw = TRUE);
- #if (WINVER >= 0x400)
- HICON SetIcon(HICON hIcon);
- HICON GetIcon() const;
- HBITMAP SetBitmap(HBITMAP hBitmap);
- HBITMAP GetBitmap() const;
- HCURSOR SetCursor(HCURSOR hCursor);
- HCURSOR GetCursor();
- #endif
- // Overridables (for owner draw only)
- virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
- // Implementation
- public:
- virtual ~CButton();
- protected:
- virtual BOOL OnChildNotify(UINT, WPARAM, LPARAM, LRESULT*);
- };
- class CListBox : public CWnd
- {
- DECLARE_DYNAMIC(CListBox)
- // Constructors
- public:
- CListBox();
- BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
- // Attributes
- // for entire listbox
- int GetCount() const;
- int GetHorizontalExtent() const;
- void SetHorizontalExtent(int cxExtent);
- int GetTopIndex() const;
- int SetTopIndex(int nIndex);
- LCID GetLocale() const;
- LCID SetLocale(LCID nNewLocale);
- #if (WINVER >= 0x400)
- int InitStorage(int nItems, UINT nBytes);
- UINT ItemFromPoint(CPoint pt, BOOL& bOutside) const;
- #endif
- // for single-selection listboxes
- int GetCurSel() const;
- int SetCurSel(int nSelect);
- // for multiple-selection listboxes
- int GetSel(int nIndex) const; // also works for single-selection
- int SetSel(int nIndex, BOOL bSelect = TRUE);
- int GetSelCount() const;
- int GetSelItems(int nMaxItems, LPINT rgIndex) const;
- void SetAnchorIndex(int nIndex);
- int GetAnchorIndex() const;
- // for listbox items
- DWORD GetItemData(int nIndex) const;
- int SetItemData(int nIndex, DWORD dwItemData);
- void* GetItemDataPtr(int nIndex) const;
- int SetItemDataPtr(int nIndex, void* pData);
- int GetItemRect(int nIndex, LPRECT lpRect) const;
- int GetText(int nIndex, LPTSTR lpszBuffer) const;
- void GetText(int nIndex, CString& rString) const;
- int GetTextLen(int nIndex) const;
- // Settable only attributes
- void SetColumnWidth(int cxWidth);
- BOOL SetTabStops(int nTabStops, LPINT rgTabStops);
- void SetTabStops();
- BOOL SetTabStops(const int& cxEachStop); // takes an 'int'
- int SetItemHeight(int nIndex, UINT cyItemHeight);
- int GetItemHeight(int nIndex) const;
- int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const;
- int GetCaretIndex() const;
- int SetCaretIndex(int nIndex, BOOL bScroll = TRUE);
- // Operations
- // manipulating listbox items
- int AddString(LPCTSTR lpszItem);
- int DeleteString(UINT nIndex);
- int InsertString(int nIndex, LPCTSTR lpszItem);
- void ResetContent();
- int Dir(UINT attr, LPCTSTR lpszWildCard);
- // selection helpers
- int FindString(int nStartAfter, LPCTSTR lpszItem) const;
- int SelectString(int nStartAfter, LPCTSTR lpszItem);
- int SelItemRange(BOOL bSelect, int nFirstItem, int nLastItem);
- // Overridables (must override draw, measure and compare for owner draw)
- virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
- virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
- virtual int CompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct);
- virtual void DeleteItem(LPDELETEITEMSTRUCT lpDeleteItemStruct);
- virtual int VKeyToItem(UINT nKey, UINT nIndex);
- virtual int CharToItem(UINT nKey, UINT nIndex);
- // Implementation
- public:
- virtual ~CListBox();
- protected:
- virtual BOOL OnChildNotify(UINT, WPARAM, LPARAM, LRESULT*);
- };
- class CCheckListBox : public CListBox
- {
- DECLARE_DYNAMIC(CCheckListBox)
- // Constructors
- public:
- CCheckListBox();
- BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
- // Attributes
- void SetCheckStyle(UINT nStyle);
- UINT GetCheckStyle();
- void SetCheck(int nIndex, int nCheck);
- int GetCheck(int nIndex);
- void Enable(int nIndex, BOOL bEnabled = TRUE);
- BOOL IsEnabled(int nIndex);
- virtual CRect OnGetCheckPosition(CRect rectItem, CRect rectCheckBox);
- // Overridables (must override draw, measure and compare for owner draw)
- virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
- virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
- // Implementation
- protected:
- void PreDrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
- void PreMeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
- int PreCompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct);
- void PreDeleteItem(LPDELETEITEMSTRUCT lpDeleteItemStruct);
- virtual BOOL OnChildNotify(UINT, WPARAM, LPARAM, LRESULT*);
- void SetSelectionCheck( int nCheck );
- #ifdef _DEBUG
- virtual void PreSubclassWindow();
- #endif
- int CalcMinimumItemHeight();
- void InvalidateCheck(int nIndex);
- void InvalidateItem(int nIndex);
- int CheckFromPoint(CPoint point, BOOL& bInCheck);
- int m_cyText;
- UINT m_nStyle;
- // Message map functions
- protected:
- //{{AFX_MSG(CCheckListBox)
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
- afx_msg LRESULT OnSetFont(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnLBAddString(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnLBFindString(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnLBFindStringExact(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnLBGetItemData(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnLBGetText(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnLBInsertString(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnLBSelectString(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnLBSetItemData(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnLBSetItemHeight(WPARAM wParam, LPARAM lParam);
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
- class CComboBox : public CWnd
- {
- DECLARE_DYNAMIC(CComboBox)
- // Constructors
- public:
- CComboBox();
- BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
- // Attributes
- // for entire combo box
- int GetCount() const;
- int GetCurSel() const;
- int SetCurSel(int nSelect);
- LCID GetLocale() const;
- LCID SetLocale(LCID nNewLocale);
- // Win4
- int GetTopIndex() const;
- int SetTopIndex(int nIndex);
- int InitStorage(int nItems, UINT nBytes);
- void SetHorizontalExtent(UINT nExtent);
- UINT GetHorizontalExtent() const;
- int SetDroppedWidth(UINT nWidth);
- int GetDroppedWidth() const;
- // for edit control
- DWORD GetEditSel() const;
- BOOL LimitText(int nMaxChars);
- BOOL SetEditSel(int nStartChar, int nEndChar);
- // for combobox item
- DWORD GetItemData(int nIndex) const;
- int SetItemData(int nIndex, DWORD dwItemData);
- void* GetItemDataPtr(int nIndex) const;
- int SetItemDataPtr(int nIndex, void* pData);
- int GetLBText(int nIndex, LPTSTR lpszText) const;
- void GetLBText(int nIndex, CString& rString) const;
- int GetLBTextLen(int nIndex) const;
- int SetItemHeight(int nIndex, UINT cyItemHeight);
- int GetItemHeight(int nIndex) const;
- int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const;
- int SetExtendedUI(BOOL bExtended = TRUE);
- BOOL GetExtendedUI() const;
- void GetDroppedControlRect(LPRECT lprect) const;
- BOOL GetDroppedState() const;
- // Operations
- // for drop-down combo boxes
- void ShowDropDown(BOOL bShowIt = TRUE);
- // manipulating listbox items
- int AddString(LPCTSTR lpszString);
- int DeleteString(UINT nIndex);
- int InsertString(int nIndex, LPCTSTR lpszString);
- void ResetContent();
- int Dir(UINT attr, LPCTSTR lpszWildCard);
- // selection helpers
- int FindString(int nStartAfter, LPCTSTR lpszString) const;
- int SelectString(int nStartAfter, LPCTSTR lpszString);
- // Clipboard operations
- void Clear();
- void Copy();
- void Cut();
- void Paste();
- // Overridables (must override draw, measure and compare for owner draw)
- virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
- virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
- virtual int CompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct);
- virtual void DeleteItem(LPDELETEITEMSTRUCT lpDeleteItemStruct);
- // Implementation
- public:
- virtual ~CComboBox();
- protected:
- virtual BOOL OnChildNotify(UINT, WPARAM, LPARAM, LRESULT*);
- };
- class CEdit : public CWnd
- {
- DECLARE_DYNAMIC(CEdit)
- // Constructors
- public:
- CEdit();
- BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
- // Attributes
- BOOL CanUndo() const;
- int GetLineCount() const;
- BOOL GetModify() const;
- void SetModify(BOOL bModified = TRUE);
- void GetRect(LPRECT lpRect) const;
- DWORD GetSel() const;
- void GetSel(int& nStartChar, int& nEndChar) const;
- HLOCAL GetHandle() const;
- void SetHandle(HLOCAL hBuffer);
- #if (WINVER >= 0x400)
- void SetMargins(UINT nLeft, UINT nRight);
- DWORD GetMargins() const;
- void SetLimitText(UINT nMax);
- UINT GetLimitText() const;
- CPoint PosFromChar(UINT nChar) const;
- int CharFromPos(CPoint pt) const;
- #endif
- // NOTE: first word in lpszBuffer must contain the size of the buffer!
- int GetLine(int nIndex, LPTSTR lpszBuffer) const;
- int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const;
- // Operations
- void EmptyUndoBuffer();
- BOOL FmtLines(BOOL bAddEOL);
- void LimitText(int nChars = 0);
- int LineFromChar(int nIndex = -1) const;
- int LineIndex(int nLine = -1) const;
- int LineLength(int nLine = -1) const;
- void LineScroll(int nLines, int nChars = 0);
- void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo = FALSE);
- void SetPasswordChar(TCHAR ch);
- void SetRect(LPCRECT lpRect);
- void SetRectNP(LPCRECT lpRect);
- void SetSel(DWORD dwSelection, BOOL bNoScroll = FALSE);
- void SetSel(int nStartChar, int nEndChar, BOOL bNoScroll = FALSE);
- BOOL SetTabStops(int nTabStops, LPINT rgTabStops);
- void SetTabStops();
- BOOL SetTabStops(const int& cxEachStop); // takes an 'int'
- // Clipboard operations
- BOOL Undo();
- void Clear();
- void Copy();
- void Cut();
- void Paste();
- BOOL SetReadOnly(BOOL bReadOnly = TRUE);
- int GetFirstVisibleLine() const;
- TCHAR GetPasswordChar() const;
- // Implementation
- public:
- virtual ~CEdit();
- };
- class CScrollBar : public CWnd
- {
- DECLARE_DYNAMIC(CScrollBar)
- // Constructors
- public:
- CScrollBar();
- BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
- // Attributes
- int GetScrollPos() const;
- int SetScrollPos(int nPos, BOOL bRedraw = TRUE);
- void GetScrollRange(LPINT lpMinPos, LPINT lpMaxPos) const;
- void SetScrollRange(int nMinPos, int nMaxPos, BOOL bRedraw = TRUE);
- void ShowScrollBar(BOOL bShow = TRUE);
- BOOL EnableScrollBar(UINT nArrowFlags = ESB_ENABLE_BOTH);
- BOOL SetScrollInfo(LPSCROLLINFO lpScrollInfo, BOOL bRedraw = TRUE);
- BOOL GetScrollInfo(LPSCROLLINFO lpScrollInfo, UINT nMask = SIF_ALL);
- int GetScrollLimit();
- // Implementation
- public:
- virtual ~CScrollBar();
- };
- /////////////////////////////////////////////////////////////////////////////
- // CFrameWnd - base class for SDI and other frame windows
- // Frame window styles
- #define FWS_ADDTOTITLE 0x00008000L // modify title based on content
- #define FWS_PREFIXTITLE 0x00004000L // show document name before app name
- #define FWS_SNAPTOBARS 0x00002000L // snap size to size of contained bars
- struct CPrintPreviewState; // forward reference (see afxext.h)
- class CControlBar; // forward reference (see afxext.h)
- class CReBar; // forward reference (see afxext.h)
- class CDockBar; // forward reference (see afxpriv.h)
- class CMiniDockFrameWnd; // forward reference (see afxpriv.h)
- class CDockState; // forward reference (see afxpriv.h)
- class COleFrameHook; // forward reference (see ..\src\oleimpl2.h)
- class CFrameWnd : public CWnd
- {
- DECLARE_DYNCREATE(CFrameWnd)
- // Constructors
- public:
- static AFX_DATA const CRect rectDefault;
- CFrameWnd();
- BOOL LoadAccelTable(LPCTSTR lpszResourceName);
- BOOL Create(LPCTSTR lpszClassName,
- LPCTSTR lpszWindowName,
- DWORD dwStyle = WS_OVERLAPPEDWINDOW,
- const RECT& rect = rectDefault,
- CWnd* pParentWnd = NULL, // != NULL for popups
- LPCTSTR lpszMenuName = NULL,
- DWORD dwExStyle = 0,
- CCreateContext* pContext = NULL);
- // dynamic creation - load frame and associated resources
- virtual BOOL LoadFrame(UINT nIDResource,
- DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE,
- CWnd* pParentWnd = NULL,
- CCreateContext* pContext = NULL);
- // special helper for view creation
- CWnd* CreateView(CCreateContext* pContext, UINT nID = AFX_IDW_PANE_FIRST);
- // Attributes
- virtual CDocument* GetActiveDocument();
- // Active child view maintenance
- CView* GetActiveView() const; // active view or NULL
- void SetActiveView(CView* pViewNew, BOOL bNotify = TRUE);
- // active view or NULL, bNotify == FALSE if focus should not be set
- // Active frame (for frames within frames -- MDI)
- virtual CFrameWnd* GetActiveFrame();
- // For customizing the default messages on the status bar
- virtual void GetMessageString(UINT nID, CString& rMessage) const;
- BOOL m_bAutoMenuEnable;
- // TRUE => menu items without handlers will be disabled
- BOOL IsTracking() const;
- // Operations
- virtual void RecalcLayout(BOOL bNotify = TRUE);
- virtual void ActivateFrame(int nCmdShow = -1);
- void InitialUpdateFrame(CDocument* pDoc, BOOL bMakeVisible);
- void SetTitle(LPCTSTR lpszTitle);
- CString GetTitle() const;
- // to set text of standard status bar
- void SetMessageText(LPCTSTR lpszText);
- void SetMessageText(UINT nID);
- // control bar docking
- void EnableDocking(DWORD dwDockStyle);
- void DockControlBar(CControlBar* pBar, UINT nDockBarID = 0,
- LPCRECT lpRect = NULL);
- void FloatControlBar(CControlBar* pBar, CPoint point,
- DWORD dwStyle = CBRS_ALIGN_TOP);
- CControlBar* GetControlBar(UINT nID);
- // frame window based modality
- virtual void BeginModalState();
- virtual void EndModalState();
- BOOL InModalState() const;
- void ShowOwnedWindows(BOOL bShow);
- // saving and loading control bar state
- void LoadBarState(LPCTSTR lpszProfileName);
- void SaveBarState(LPCTSTR lpszProfileName) const;
- void ShowControlBar(CControlBar* pBar, BOOL bShow, BOOL bDelay);
- void SetDockState(const CDockState& state);
- void GetDockState(CDockState& state) const;
- // Overridables
- virtual void OnSetPreviewMode(BOOL bPreview, CPrintPreviewState* pState);
- virtual CWnd* GetMessageBar();
- // border space negotiation
- enum BorderCmd
- { borderGet = 1, borderRequest = 2, borderSet = 3 };
- virtual BOOL NegotiateBorderSpace(UINT nBorderCmd, LPRECT lpRectBorder);
- protected:
- virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
- // Command Handlers
- public:
- afx_msg void OnContextHelp(); // for Shift+F1 help
- afx_msg void OnUpdateControlBarMenu(CCmdUI* pCmdUI);
- afx_msg BOOL OnBarCheck(UINT nID);
- // Implementation
- public:
- virtual ~CFrameWnd();
- int m_nWindow; // general purpose window number - display as ":n"
- // -1 => unknown, 0 => only window viewing document
- // 1 => first of many windows viewing document, 2=> second
- HMENU m_hMenuDefault; // default menu resource for this frame
- HACCEL m_hAccelTable; // accelerator table
- DWORD m_dwPromptContext; // current help prompt context for message box
- BOOL m_bHelpMode; // if TRUE, then Shift+F1 help mode is active
- CFrameWnd* m_pNextFrameWnd; // next CFrameWnd in app global list
- CRect m_rectBorder; // for OLE border space negotiation
- COleFrameHook* m_pNotifyHook;
- CPtrList m_listControlBars; // array of all control bars that have this
- // window as their dock site
- int m_nShowDelay; // SW_ command for delay show/hide
- CMiniDockFrameWnd* CreateFloatingFrame(DWORD dwStyle);
- DWORD CanDock(CRect rect, DWORD dwDockStyle,
- CDockBar** ppDockBar = NULL); // called by CDockContext
- void AddControlBar(CControlBar *pBar);
- void RemoveControlBar(CControlBar *pBar);
- void DockControlBar(CControlBar* pBar, CDockBar* pDockBar,
- LPCRECT lpRect = NULL);
- void ReDockControlBar(CControlBar* pBar, CDockBar* pDockBar,
- LPCRECT lpRect = NULL);
- void NotifyFloatingWindows(DWORD dwFlags);
- void DestroyDockBars();
- protected:
- UINT m_nIDHelp; // Help ID (0 for none, see HID_BASE_RESOURCE)
- UINT m_nIDTracking; // tracking command ID or string IDS
- UINT m_nIDLastMessage; // last displayed message string IDS
- CView* m_pViewActive; // current active view
- BOOL (CALLBACK* m_lpfnCloseProc)(CFrameWnd* pFrameWnd);
- UINT m_cModalStack; // BeginModalState depth
- HWND* m_phWndDisable; // windows disabled because of BeginModalState
- HMENU m_hMenuAlt; // menu to update to (NULL means default)
- CString m_strTitle; // default title (original)
- BOOL m_bInRecalcLayout; // avoid recursion in RecalcLayout
- CRuntimeClass* m_pFloatingFrameClass;
- static const DWORD dwDockBarMap[4][2];
- public:
- #ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
- #endif
- virtual BOOL IsFrameWnd() const;
- virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra,
- AFX_CMDHANDLERINFO* pHandlerInfo);
- virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
- virtual void OnUpdateFrameMenu(HMENU hMenuAlt);
- virtual HACCEL GetDefaultAccelerator();
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- // idle update of frame user interface
- enum IdleFlags
- { idleMenu = 1, idleTitle = 2, idleNotify = 4, idleLayout = 8 };
- UINT m_nIdleFlags; // set of bit flags for idle processing
- virtual void DelayUpdateFrameMenu(HMENU hMenuAlt);
- void DelayUpdateFrameTitle();
- void DelayRecalcLayout(BOOL bNotify = TRUE);
- // for Shift+F1 help support
- BOOL CanEnterHelpMode();
- virtual void ExitHelpMode();
- // implementation helpers
- public:
- void UpdateFrameTitleForDocument(LPCTSTR lpszDocName);
- protected:
- LPCTSTR GetIconWndClass(DWORD dwDefaultStyle, UINT nIDResource);
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
- virtual void PostNcDestroy(); // default to delete this.
- int OnCreateHelper(LPCREATESTRUCT lpcs, CCreateContext* pContext);
- void BringToTop(int nCmdShow);
- // bring window to top for SW_ commands which affect z-order
- // implementation helpers for Shift+F1 help mode
- BOOL ProcessHelpMsg(MSG& msg, DWORD* pContext);
- HWND SetHelpCapture(POINT point, BOOL* pbDescendant);
- // CFrameWnd list management
- void AddFrameWnd();
- void RemoveFrameWnd();
- friend class CWnd; // for access to m_bModalDisable
- friend class CReBar; // for access to m_bInRecalcLayout
- //{{AFX_MSG(CFrameWnd)
- // Windows messages
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg void OnDestroy();
- afx_msg void OnClose();
- afx_msg void OnInitMenu(CMenu*);
- afx_msg void OnInitMenuPopup(CMenu*, UINT, BOOL);
- afx_msg void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu);
- afx_msg LRESULT OnPopMessageString(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnSetMessageString(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnHelpPromptAddr(WPARAM wParam, LPARAM lParam);
- afx_msg void OnIdleUpdateCmdUI();
- afx_msg void OnEnterIdle(UINT nWhy, CWnd* pWho);
- afx_msg void OnSetFocus(CWnd* pOldWnd);
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
- afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
- afx_msg BOOL OnNcActivate(BOOL bActive);
- afx_msg void OnSysCommand(UINT nID, LONG lParam);
- afx_msg BOOL OnQueryEndSession();
- afx_msg void OnEndSession(BOOL bEnding);
- afx_msg void OnDropFiles(HDROP hDropInfo);
- afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
- afx_msg LRESULT OnCommandHelp(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnHelpHitTest(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnActivateTopLevel(WPARAM wParam, LPARAM lParam);
- afx_msg void OnEnable(BOOL bEnable);
- afx_msg void OnPaletteChanged(CWnd* pFocusWnd);
- afx_msg BOOL OnQueryNewPalette();
- // standard commands
- afx_msg BOOL OnToolTipText(UINT nID, NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnUpdateKeyIndicator(CCmdUI* pCmdUI);
- afx_msg void OnHelp();
- afx_msg void OnUpdateContextHelp(CCmdUI* pCmdUI);
- //}}AFX_MSG
- protected:
- afx_msg LRESULT OnDDEInitiate(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnDDEExecute(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnDDETerminate(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnRegisteredMouseWheel(WPARAM wParam, LPARAM lParam);
- DECLARE_MESSAGE_MAP()
- friend class CWinApp;
- };
- /////////////////////////////////////////////////////////////////////////////
- // MDI Support
- class CMDIFrameWnd : public CFrameWnd
- {
- DECLARE_DYNCREATE(CMDIFrameWnd)
- public:
- // Constructors
- CMDIFrameWnd();
- // Operations
- void MDIActivate(CWnd* pWndActivate);
- CMDIChildWnd* MDIGetActive(BOOL* pbMaximized = NULL) const;
- void MDIIconArrange();
- void MDIMaximize(CWnd* pWnd);
- void MDINext();
- void MDIRestore(CWnd* pWnd);
- CMenu* MDISetMenu(CMenu* pFrameMenu, CMenu* pWindowMenu);
- void MDITile();
- void MDICascade();
- void MDITile(int nType);
- void MDICascade(int nType);
- CMDIChildWnd* CreateNewChild(CRuntimeClass* pClass, UINT nResource,
- HMENU hMenu = NULL, HACCEL hAccel = NULL);
- // Overridables
- // MFC 1.0 backward compatible CreateClient hook (called by OnCreateClient)
- virtual BOOL CreateClient(LPCREATESTRUCT lpCreateStruct, CMenu* pWindowMenu);
- // customize if using an 'Window' menu with non-standard IDs
- virtual HMENU GetWindowMenuPopup(HMENU hMenuBar);
- // Implementation
- public:
- HWND m_hWndMDIClient; // MDI Client window handle
- #ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
- #endif
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- virtual BOOL LoadFrame(UINT nIDResource,
- DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE,
- CWnd* pParentWnd = NULL,
- CCreateContext* pContext = NULL);
- virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
- virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra,
- AFX_CMDHANDLERINFO* pHandlerInfo);
- virtual void OnUpdateFrameMenu(HMENU hMenuAlt);
- virtual void DelayUpdateFrameMenu(HMENU hMenuAlt);
- virtual CFrameWnd* GetActiveFrame();
- protected:
- virtual LRESULT DefWindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam);
- virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
- //{{AFX_MSG(CMDIFrameWnd)
- afx_msg void OnDestroy();
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnUpdateMDIWindowCmd(CCmdUI* pCmdUI);
- afx_msg BOOL OnMDIWindowCmd(UINT nID);
- afx_msg void OnWindowNew();
- afx_msg LRESULT OnCommandHelp(WPARAM wParam, LPARAM lParam);
- afx_msg void OnIdleUpdateCmdUI();
- afx_msg LRESULT OnMenuChar(UINT nChar, UINT, CMenu*);
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
- class CMDIChildWnd : public CFrameWnd
- {
- DECLARE_DYNCREATE(CMDIChildWnd)
- // Constructors
- public:
- CMDIChildWnd();
- virtual BOOL Create(LPCTSTR lpszClassName,
- LPCTSTR lpszWindowName,
- DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW,
- const RECT& rect = rectDefault,
- CMDIFrameWnd* pParentWnd = NULL,
- CCreateContext* pContext = NULL);
- // Attributes
- CMDIFrameWnd* GetMDIFrame();
- // Operations
- void MDIDestroy();
- void MDIActivate();
- void MDIMaximize();
- void MDIRestore();
- void SetHandles(HMENU hMenu, HACCEL hAccel);
- // Implementation
- protected:
- HMENU m_hMenuShared; // menu when we are active
- public:
- #ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
- #endif
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- virtual BOOL LoadFrame(UINT nIDResource, DWORD dwDefaultStyle,
- CWnd* pParentWnd, CCreateContext* pContext = NULL);
- // 'pParentWnd' parameter is required for MDI Child
- virtual BOOL DestroyWindow();
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- virtual void ActivateFrame(int nCmdShow = -1);
- virtual void OnUpdateFrameMenu(BOOL bActive, CWnd* pActivateWnd,
- HMENU hMenuAlt);
- BOOL m_bPseudoInactive; // TRUE if window is MDI active according to
- // windows, but not according to MFC...
- protected:
- virtual CWnd* GetMessageBar();
- virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
- virtual LRESULT DefWindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam);
- BOOL UpdateClientEdge(LPRECT lpRect = NULL);
- //{{AFX_MSG(CMDIChildWnd)
- afx_msg void OnMDIActivate(BOOL bActivate, CWnd*, CWnd*);
- afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg BOOL OnNcCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnWindowPosChanging(LPWINDOWPOS lpWndPos);
- afx_msg BOOL OnNcActivate(BOOL bActive);
- afx_msg void OnDestroy();
- afx_msg BOOL OnToolTipText(UINT nID, NMHDR* pNMHDR, LRESULT* pResult);
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
- /////////////////////////////////////////////////////////////////////////////
- // CMiniFrameWnd
- // MiniFrame window styles
- #define MFS_SYNCACTIVE 0x00000100L // syncronize activation w/ parent
- #define MFS_4THICKFRAME 0x00000200L // thick frame all around (no tiles)
- #define MFS_THICKFRAME 0x00000400L // use instead of WS_THICKFRAME
- #define MFS_MOVEFRAME 0x00000800L // no sizing, just moving
- #define MFS_BLOCKSYSMENU 0x00001000L // block hit testing on system menu
- class CMiniFrameWnd : public CFrameWnd
- {
- DECLARE_DYNCREATE(CMiniFrameWnd)
- // Constructors
- public:
- CMiniFrameWnd();
- BOOL Create(LPCTSTR lpClassName, LPCTSTR lpWindowName,
- DWORD dwStyle, const RECT& rect,
- CWnd* pParentWnd = NULL, UINT nID = 0);
- BOOL CreateEx(DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName,
- DWORD dwStyle, const RECT& rect,
- CWnd* pParentWnd = NULL, UINT nID = 0);
- // Implementation
- public:
- ~CMiniFrameWnd();
- static void AFX_CDECL Initialize();
- //{{AFX_MSG(CMiniFrameWnd)
- afx_msg BOOL OnNcActivate(BOOL bActive);
- afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpParams);
- afx_msg UINT OnNcHitTest(CPoint point);
- afx_msg void OnNcPaint();
- afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint pt);
- afx_msg void OnLButtonUp(UINT nFlags, CPoint pt);
- afx_msg void OnMouseMove(UINT nFlags, CPoint pt);
- afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
- afx_msg void OnGetMinMaxInfo(MINMAXINFO* pMMI);
- afx_msg LRESULT OnGetText(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnGetTextLength(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnFloatStatus(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnQueryCenterWnd(WPARAM wParam, LPARAM lParam);
- afx_msg BOOL OnNcCreate(LPCREATESTRUCT lpcs);
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- public:
- virtual void CalcWindowRect(LPRECT lpClientRect,
- UINT nAdjustType = adjustBorder);
- static void PASCAL CalcBorders(LPRECT lpClientRect,
- DWORD dwStyle = WS_THICKFRAME | WS_CAPTION, DWORD dwExStyle = 0);
- protected:
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- protected:
- BOOL m_bSysTracking;
- BOOL m_bInSys;
- BOOL m_bActive;
- CString m_strCaption;
- void InvertSysMenu();
- };
- /////////////////////////////////////////////////////////////////////////////
- // class CView is the client area UI for a document
- class CPrintDialog; // forward reference (see afxdlgs.h)
- class CPreviewView; // forward reference (see afxpriv.h)
- class CSplitterWnd; // forward reference (see afxext.h)
- class COleServerDoc; // forward reference (see afxole.h)
- typedef DWORD DROPEFFECT;
- class COleDataObject; // forward reference (see afxole.h)
- #ifdef _AFXDLL
- class CView : public CWnd
- #else
- class AFX_NOVTABLE CView : public CWnd
- #endif
- {
- DECLARE_DYNAMIC(CView)
- // Constructors
- protected:
- CView();
- // Attributes
- public:
- CDocument* GetDocument() const;
- // Operations
- public:
- // for standard printing setup (override OnPreparePrinting)
- BOOL DoPreparePrinting(CPrintInfo* pInfo);
- // Overridables
- public:
- virtual BOOL IsSelected(const CObject* pDocItem) const; // support for OLE
- // OLE scrolling support (used for drag/drop as well)
- virtual BOOL OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll = TRUE);
- virtual BOOL OnScrollBy(CSize sizeScroll, BOOL bDoScroll = TRUE);
- // OLE drag/drop support
- virtual DROPEFFECT OnDragEnter(COleDataObject* pDataObject,
- DWORD dwKeyState, CPoint point);
- virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject,
- DWORD dwKeyState, CPoint point);
- virtual void OnDragLeave();
- virtual BOOL OnDrop(COleDataObject* pDataObject,
- DROPEFFECT dropEffect, CPoint point);
- virtual DROPEFFECT OnDropEx(COleDataObject* pDataObject,
- DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point);
- virtual DROPEFFECT OnDragScroll(DWORD dwKeyState, CPoint point);
- virtual void OnPrepareDC(CDC* pDC, CPrintInfo* pInfo = NULL);
- virtual void OnInitialUpdate(); // called first time after construct
- protected:
- // Activation
- virtual void OnActivateView(BOOL bActivate, CView* pActivateView,
- CView* pDeactiveView);
- virtual void OnActivateFrame(UINT nState, CFrameWnd* pFrameWnd);
- // General drawing/updating
- virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
- virtual void OnDraw(CDC* pDC) = 0;
- // Printing support
- virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
- // must override to enable printing and print preview
- virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
- virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo);
- virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
- // Advanced: end print preview mode, move to point
- virtual void OnEndPrintPreview(CDC* pDC, CPrintInfo* pInfo, POINT point,
- CPreviewView* pView);
- // Implementation
- public:
- virtual ~CView();
- #ifdef _DEBUG
- virtual void Dump(CDumpContext&) const;
- virtual void AssertValid() const;
- #endif //_DEBUG
- // Advanced: for implementing custom print preview
- BOOL DoPrintPreview(UINT nIDResource, CView* pPrintView,
- CRuntimeClass* pPreviewViewClass, CPrintPreviewState* pState);
- virtual void CalcWindowRect(LPRECT lpClientRect,
- UINT nAdjustType = adjustBorder);
- virtual CScrollBar* GetScrollBarCtrl(int nBar) const;
- static CSplitterWnd* PASCAL GetParentSplitter(
- const CWnd* pWnd, BOOL bAnyState);
- protected:
- CDocument* m_pDocument;
- public:
- virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra,
- AFX_CMDHANDLERINFO* pHandlerInfo);
- protected:
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- virtual void PostNcDestroy();
- // friend classes that call protected CView overridables
- friend class CDocument;
- friend class CDocTemplate;
- friend class CPreviewView;
- friend class CFrameWnd;
- friend class CMDIFrameWnd;
- friend class CMDIChildWnd;
- friend class CSplitterWnd;
- friend class COleServerDoc;
- friend class CDocObjectServer;
- //{{AFX_MSG(CView)
- afx_msg int OnCreate(LPCREATESTRUCT lpcs);
- afx_msg void OnDestroy();
- afx_msg void OnPaint();
- afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
- // commands
- afx_msg void OnUpdateSplitCmd(CCmdUI* pCmdUI);
- afx_msg BOOL OnSplitCmd(UINT nID);
- afx_msg void OnUpdateNextPaneMenu(CCmdUI* pCmdUI);
- afx_msg BOOL OnNextPaneCmd(UINT nID);
- // not mapped commands - must be mapped in derived class
- afx_msg void OnFilePrint();
- afx_msg void OnFilePrintPreview();
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
- /////////////////////////////////////////////////////////////////////////////
- // class CCtrlView allows almost any control to be a view
- #ifdef _AFXDLL
- class CCtrlView : public CView
- #else
- class AFX_NOVTABLE CCtrlView : public CView
- #endif
- {
- DECLARE_DYNCREATE(CCtrlView)
- public:
- CCtrlView(LPCTSTR lpszClass, DWORD dwStyle);
- // Attributes
- protected:
- CString m_strClass;
- DWORD m_dwDefaultStyle;
- // Overrides
- virtual void OnDraw(CDC*);
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- // Implementation
- public:
- #ifdef _DEBUG
- virtual void Dump(CDumpContext&) const;
- virtual void AssertValid() const;
- #endif //_DEBUG
- protected:
- afx_msg void OnPaint();
- DECLARE_MESSAGE_MAP()
- };
- /////////////////////////////////////////////////////////////////////////////
- // class CScrollView supports simple scrolling and scaling
- class CScrollView : public CView
- {
- DECLARE_DYNAMIC(CScrollView)
- // Constructors
- protected:
- CScrollView();
- public:
- static AFX_DATA const SIZE sizeDefault;
- // used to specify default calculated page and line sizes
- // in logical units - call one of the following Set routines
- void SetScaleToFitSize(SIZE sizeTotal);
- void SetScrollSizes(int nMapMode, SIZE sizeTotal,
- const SIZE& sizePage = sizeDefault,
- const SIZE& sizeLine = sizeDefault);
- // Attributes
- public:
- CPoint GetScrollPosition() const; // upper corner of scrolling
- CSize GetTotalSize() const; // logical size
- // for device units
- CPoint GetDeviceScrollPosition() const;
- void GetDeviceScrollSizes(int& nMapMode, SIZE& sizeTotal,
- SIZE& sizePage, SIZE& sizeLine) const;
- // Operations
- public:
- void ScrollToPosition(POINT pt); // set upper left position
- void FillOutsideRect(CDC* pDC, CBrush* pBrush);
- void ResizeParentToFit(BOOL bShrinkOnly = TRUE);
- BOOL DoMouseWheel(UINT fFlags, short zDelta, CPoint point);
- // Implementation
- protected:
- int m_nMapMode;
- CSize m_totalLog; // total size in logical units (no rounding)
- CSize m_totalDev; // total size in device units
- CSize m_pageDev; // per page scroll size in device units
- CSize m_lineDev; // per line scroll size in device units
- BOOL m_bCenter; // Center output if larger than total size
- BOOL m_bInsideUpdate; // internal state for OnSize callback
- void CenterOnPoint(CPoint ptCenter);
- void ScrollToDevicePosition(POINT ptDev); // explicit scrolling no checking
- protected:
- virtual void OnDraw(CDC* pDC) = 0; // pass on pure virtual
- void UpdateBars(); // adjust scrollbars etc
- BOOL GetTrueClientSize(CSize& size, CSize& sizeSb);
- // size with no bars
- void GetScrollBarSizes(CSize& sizeSb);
- void GetScrollBarState(CSize sizeClient, CSize& needSb,
- CSize& sizeRange, CPoint& ptMove, BOOL bInsideClient);
- public:
- virtual ~CScrollView();
- #ifdef _DEBUG
- virtual void Dump(CDumpContext&) const;
- virtual void AssertValid() const;
- #endif //_DEBUG
- virtual void CalcWindowRect(LPRECT lpClientRect,
- UINT nAdjustType = adjustBorder);
- virtual void OnPrepareDC(CDC* pDC, CPrintInfo* pInfo = NULL);
- // scrolling implementation support for OLE
- virtual BOOL OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll = TRUE);
- virtual BOOL OnScrollBy(CSize sizeScroll, BOOL bDoScroll = TRUE);
- //{{AFX_MSG(CScrollView)
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
- afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
- afx_msg BOOL OnMouseWheel(UINT fFlags, short zDelta, CPoint point);
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
- /////////////////////////////////////////////////////////////////////////////
- // CWinThread
- typedef UINT (AFX_CDECL *AFX_THREADPROC)(LPVOID);
- class COleMessageFilter; // forward reference (see afxole.h)
- class CWinThread : public CCmdTarget
- {
- DECLARE_DYNAMIC(CWinThread)
- public:
- // Constructors
- CWinThread();
- BOOL CreateThread(DWORD dwCreateFlags = 0, UINT nStackSize = 0,
- LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL);
- // Attributes
- CWnd* m_pMainWnd; // main window (usually same AfxGetApp()->m_pMainWnd)
- CWnd* m_pActiveWnd; // active main window (may not be m_pMainWnd)
- BOOL m_bAutoDelete; // enables 'delete this' after thread termination
- // only valid while running
- HANDLE m_hThread; // this thread's HANDLE
- operator HANDLE() const;
- DWORD m_nThreadID; // this thread's ID
- int GetThreadPriority();
- BOOL SetThreadPriority(int nPriority);
- // Operations
- DWORD SuspendThread();
- DWORD ResumeThread();
- BOOL PostThreadMessage(UINT message, WPARAM wParam, LPARAM lParam);
- // Overridables
- // thread initialization
- virtual BOOL InitInstance();
- // running and idle processing
- virtual int Run();
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- virtual BOOL PumpMessage(); // low level message pump
- virtual BOOL OnIdle(LONG lCount); // return TRUE if more idle processing
- virtual BOOL IsIdleMessage(MSG* pMsg); // checks for special messages
- // thread termination
- virtual int ExitInstance(); // default will 'delete this'
- // Advanced: exception handling
- virtual LRESULT ProcessWndProcException(CException* e, const MSG* pMsg);
- // Advanced: handling messages sent to message filter hook
- virtual BOOL ProcessMessageFilter(int code, LPMSG lpMsg);
- // Advanced: virtual access to m_pMainWnd
- virtual CWnd* GetMainWnd();
- // Implementation
- public:
- virtual ~CWinThread();
- #ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
- int m_nDisablePumpCount; // Diagnostic trap to detect illegal re-entrancy
- #endif
- void CommonConstruct();
- virtual void Delete();
- // 'delete this' only if m_bAutoDelete == TRUE
- // message pump for Run
- MSG m_msgCur; // current message
- public:
- // constructor used by implementation of AfxBeginThread
- CWinThread(AFX_THREADPROC pfnThreadProc, LPVOID pParam);
- // valid after construction
- LPVOID m_pThreadParams; // generic parameters passed to starting function
- AFX_THREADPROC m_pfnThreadProc;
- // set after OLE is initialized
- void (AFXAPI* m_lpfnOleTermOrFreeLib)(BOOL, BOOL);
- COleMessageFilter* m_pMessageFilter;
- protected:
- CPoint m_ptCursorLast; // last mouse position
- UINT m_nMsgLast; // last mouse message
- BOOL DispatchThreadMessageEx(MSG* msg); // helper
- void DispatchThreadMessage(MSG* msg); // obsolete
- };
- // global helpers for threads
- CWinThread* AFXAPI AfxBeginThread(AFX_THREADPROC pfnThreadProc, LPVOID pParam,
- int nPriority = THREAD_PRIORITY_NORMAL, UINT nStackSize = 0,
- DWORD dwCreateFlags = 0, LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL);
- CWinThread* AFXAPI AfxBeginThread(CRuntimeClass* pThreadClass,
- int nPriority = THREAD_PRIORITY_NORMAL, UINT nStackSize = 0,
- DWORD dwCreateFlags = 0, LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL);
- CWinThread* AFXAPI AfxGetThread();
- void AFXAPI AfxEndThread(UINT nExitCode, BOOL bDelete = TRUE);
- void AFXAPI AfxInitThread();
- void AFXAPI AfxTermThread(HINSTANCE hInstTerm = NULL);
- /////////////////////////////////////////////////////////////////////////////
- // Global functions for access to the one and only CWinApp
- #define afxCurrentWinApp AfxGetModuleState()->m_pCurrentWinApp
- #define afxCurrentInstanceHandle AfxGetModuleState()->m_hCurrentInstanceHandle
- #define afxCurrentResourceHandle AfxGetModuleState()->m_hCurrentResourceHandle
- #define afxCurrentAppName AfxGetModuleState()->m_lpszCurrentAppName
- #define afxContextIsDLL AfxGetModuleState()->m_bDLL
- #define afxRegisteredClasses AfxGetModuleState()->m_fRegisteredClasses
- #ifndef _AFX_NO_OCC_SUPPORT
- #define afxOccManager AfxGetModuleState()->m_pOccManager
- #endif
- // Advanced initialization: for overriding default WinMain
- BOOL AFXAPI AfxWinInit(HINSTANCE hInstance, HINSTANCE hPrevInstance,
- LPTSTR lpCmdLine, int nCmdShow);
- void AFXAPI AfxWinTerm();
- // Global Windows state data helper functions (inlines)
- CWinApp* AFXAPI AfxGetApp();
- CWnd* AFXAPI AfxGetMainWnd();
- HINSTANCE AFXAPI AfxGetInstanceHandle();
- HINSTANCE AFXAPI AfxGetResourceHandle();
- void AFXAPI AfxSetResourceHandle(HINSTANCE hInstResource);
- LPCTSTR AFXAPI AfxGetAppName();
- // Use instead of PostQuitMessage in OLE server applications
- void AFXAPI AfxPostQuitMessage(int nExitCode);
- // Use AfxFindResourceHandle to find resource in chain of extension DLLs
- #ifndef _AFXDLL
- #define AfxFindResourceHandle(lpszResource, lpszType) AfxGetResourceHandle()
- #else
- HINSTANCE AFXAPI AfxFindResourceHandle(LPCTSTR lpszName, LPCTSTR lpszType);
- #endif
- LONG AFXAPI AfxDelRegTreeHelper(HKEY hParentKey, const CString& strKeyName);
- class CRecentFileList; // forward reference (see afxpriv.h)
- // access to message filter in CWinApp
- COleMessageFilter* AFXAPI AfxOleGetMessageFilter();
- /////////////////////////////////////////////////////////////////////////////
- // CCommandLineInfo
- class CCommandLineInfo : public CObject
- {
- public:
- // Sets default values
- CCommandLineInfo();
- //plain char* version on UNICODE for source-code backwards compatibility
- virtual void ParseParam(const TCHAR* pszParam, BOOL bFlag, BOOL bLast);
- #ifdef _UNICODE
- virtual void ParseParam(const char* pszParam, BOOL bFlag, BOOL bLast);
- #endif
- BOOL m_bShowSplash;
- BOOL m_bRunEmbedded;
- BOOL m_bRunAutomated;
- enum { FileNew, FileOpen, FilePrint, FilePrintTo, FileDDE,
- AppUnregister, FileNothing = -1 } m_nShellCommand;
- // not valid for FileNew
- CString m_strFileName;
- // valid only for FilePrintTo
- CString m_strPrinterName;
- CString m_strDriverName;
- CString m_strPortName;
- ~CCommandLineInfo();
- // Implementation
- protected:
- void ParseParamFlag(const char* pszParam);
- void ParseParamNotFlag(const TCHAR* pszParam);
- #ifdef _UNICODE
- void ParseParamNotFlag(const char* pszParam);
- #endif
- void ParseLast(BOOL bLast);
- };
- /////////////////////////////////////////////////////////////////////////////
- // CDocManager
- class CDocManager : public CObject
- {
- DECLARE_DYNAMIC(CDocManager)
- public:
- // Constructor
- CDocManager();
- //Document functions
- virtual void AddDocTemplate(CDocTemplate* pTemplate);
- virtual POSITION GetFirstDocTemplatePosition() const;
- virtual CDocTemplate* GetNextDocTemplate(POSITION& pos) const;
- virtual void RegisterShellFileTypes(BOOL bCompat);
- void UnregisterShellFileTypes();
- virtual CDocument* OpenDocumentFile(LPCTSTR lpszFileName); // open named file
- virtual BOOL SaveAllModified(); // save before exit
- virtual void CloseAllDocuments(BOOL bEndSession); // close documents before exiting
- virtual int GetOpenDocumentCount();
- // helper for standard commdlg dialogs
- virtual BOOL DoPromptFileName(CString& fileName, UINT nIDSTitle,
- DWORD lFlags, BOOL bOpenFileDialog, CDocTemplate* pTemplate);
- //Commands
- // Advanced: process async DDE request
- virtual BOOL OnDDECommand(LPTSTR lpszCommand);
- virtual void OnFileNew();
- virtual void OnFileOpen();
- // Implementation
- protected:
- CPtrList m_templateList;
- int GetDocumentCount(); // helper to count number of total documents
- public:
- static CPtrList* pStaticList; // for static CDocTemplate objects
- static BOOL bStaticInit; // TRUE during static initialization
- static CDocManager* pStaticDocManager; // for static CDocTemplate objects
- public:
- virtual ~CDocManager();
- #ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
- #endif
- };
- /////////////////////////////////////////////////////////////////////////////
- // CWinApp - the root of all Windows applications
- #define _AFX_MRU_COUNT 4 // default support for 4 entries in file MRU
- #define _AFX_MRU_MAX_COUNT 16 // currently allocated id range supports 16
- class CWinApp : public CWinThread
- {
- DECLARE_DYNAMIC(CWinApp)
- public:
- // Constructor
- CWinApp(LPCTSTR lpszAppName = NULL); // app name defaults to EXE name
- // Attributes
- // Startup args (do not change)
- HINSTANCE m_hInstance;
- HINSTANCE m_hPrevInstance;
- LPTSTR m_lpCmdLine;
- int m_nCmdShow;
- // Running args (can be changed in InitInstance)
- LPCTSTR m_pszAppName; // human readable name
- // (from constructor or AFX_IDS_APP_TITLE)
- LPCTSTR m_pszRegistryKey; // used for registry entries
- CDocManager* m_pDocManager;
- // Support for Shift+F1 help mode.
- BOOL m_bHelpMode; // are we in Shift+F1 mode?
- public: // set in constructor to override default
- LPCTSTR m_pszExeName; // executable name (no spaces)
- LPCTSTR m_pszHelpFilePath; // default based on module path
- LPCTSTR m_pszProfileName; // default based on app name
- // Initialization Operations - should be done in InitInstance
- protected:
- void LoadStdProfileSettings(UINT nMaxMRU = _AFX_MRU_COUNT); // load MRU file list and last preview state
- void EnableShellOpen();
- #ifndef _AFX_NO_GRAYDLG_SUPPORT
- void SetDialogBkColor(COLORREF clrCtlBk = RGB(192, 192, 192),
- COLORREF clrCtlText = RGB(0, 0, 0));
- // set dialog box and message box background color
- #endif
- void SetRegistryKey(LPCTSTR lpszRegistryKey);
- void SetRegistryKey(UINT nIDRegistryKey);
- // enables app settings in registry instead of INI files
- // (registry key is usually a "company name")
- #ifndef _AFX_NO_CTL3D_SUPPORT
- BOOL Enable3dControls(); // use CTL3D32.DLL for 3D controls in dialogs
- #ifndef _AFXDLL
- BOOL Enable3dControlsStatic(); // statically link CTL3D.LIB instead
- #endif
- #else
- #ifdef __BORLANDC__
- // stubs to ignore the 3d stuff
- BOOL Enable3dControls() { return FALSE; }
- BOOL Enable3dControlsStatic() { return FALSE; }
- #endif
- #endif
- void RegisterShellFileTypes(BOOL bCompat=FALSE);
- // call after all doc templates are registered
- void RegisterShellFileTypesCompat();
- // for backwards compatibility
- void UnregisterShellFileTypes();
- // Helper Operations - usually done in InitInstance
- public:
- // Cursors
- HCURSOR LoadCursor(LPCTSTR lpszResourceName) const;
- HCURSOR LoadCursor(UINT nIDResource) const;
- HCURSOR LoadStandardCursor(LPCTSTR lpszCursorName) const; // for IDC_ values
- HCURSOR LoadOEMCursor(UINT nIDCursor) const; // for OCR_ values
- // Icons
- HICON LoadIcon(LPCTSTR lpszResourceName) const;
- HICON LoadIcon(UINT nIDResource) const;
- HICON LoadStandardIcon(LPCTSTR lpszIconName) const; // for IDI_ values
- HICON LoadOEMIcon(UINT nIDIcon) const; // for OIC_ values
- // Profile settings (to the app specific .INI file, or registry)
- UINT GetProfileInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, int nDefault);
- BOOL WriteProfileInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, int nValue);
- CString GetProfileString(LPCTSTR lpszSection, LPCTSTR lpszEntry,
- LPCTSTR lpszDefault = NULL);
- BOOL WriteProfileString(LPCTSTR lpszSection, LPCTSTR lpszEntry,
- LPCTSTR lpszValue);
- BOOL GetProfileBinary(LPCTSTR lpszSection, LPCTSTR lpszEntry,
- LPBYTE* ppData, UINT* pBytes);
- BOOL WriteProfileBinary(LPCTSTR lpszSection, LPCTSTR lpszEntry,
- LPBYTE pData, UINT nBytes);
- BOOL Unregister();
- LONG DelRegTree(HKEY hParentKey, const CString& strKeyName);
- // Running Operations - to be done on a running application
- // Dealing with document templates
- void AddDocTemplate(CDocTemplate* pTemplate);
- POSITION GetFirstDocTemplatePosition() const;
- CDocTemplate* GetNextDocTemplate(POSITION& pos) const;
- // Dealing with files
- virtual CDocument* OpenDocumentFile(LPCTSTR lpszFileName); // open named file
- virtual void AddToRecentFileList(LPCTSTR lpszPathName); // add to MRU
- // Printer DC Setup routine, 'struct tagPD' is a PRINTDLG structure
- void SelectPrinter(HANDLE hDevNames, HANDLE hDevMode,
- BOOL bFreeOld = TRUE);
- BOOL CreatePrinterDC(CDC& dc);
- #ifndef _UNICODE
- BOOL GetPrinterDeviceDefaults(struct tagPDA* pPrintDlg);
- #else
- BOOL GetPrinterDeviceDefaults(struct tagPDW* pPrintDlg);
- #endif
- // Command line parsing
- BOOL RunEmbedded();
- BOOL RunAutomated();
- void ParseCommandLine(CCommandLineInfo& rCmdInfo);
- BOOL ProcessShellCommand(CCommandLineInfo& rCmdInfo);
- // Overridables
- // hooks for your initialization code
- virtual BOOL InitApplication();
- // exiting
- virtual BOOL SaveAllModified(); // save before exit
- void HideApplication();
- void CloseAllDocuments(BOOL bEndSession); // close documents before exiting
- // Advanced: to override message boxes and other hooks
- virtual int DoMessageBox(LPCTSTR lpszPrompt, UINT nType, UINT nIDPrompt);
- virtual void DoWaitCursor(int nCode); // 0 => restore, 1=> begin, -1=> end
- // Advanced: process async DDE request
- virtual BOOL OnDDECommand(LPTSTR lpszCommand);
- // Advanced: Help support
- virtual void WinHelp(DWORD dwData, UINT nCmd = HELP_CONTEXT);
- // Command Handlers
- protected:
- // map to the following for file new/open
- afx_msg void OnFileNew();
- afx_msg void OnFileOpen();
- // map to the following to enable print setup
- afx_msg void OnFilePrintSetup();
- // map to the following to enable help
- afx_msg void OnContextHelp(); // shift-F1
- afx_msg void OnHelp(); // F1 (uses current context)
- afx_msg void OnHelpIndex(); // ID_HELP_INDEX
- afx_msg void OnHelpFinder(); // ID_HELP_FINDER, ID_DEFAULT_HELP
- afx_msg void OnHelpUsing(); // ID_HELP_USING
- // Implementation
- protected:
- HGLOBAL m_hDevMode; // printer Dev Mode
- HGLOBAL m_hDevNames; // printer Device Names
- DWORD m_dwPromptContext; // help context override for message box
- int m_nWaitCursorCount; // for wait cursor (>0 => waiting)
- HCURSOR m_hcurWaitCursorRestore; // old cursor to restore after wait cursor
- CRecentFileList* m_pRecentFileList;
- void UpdatePrinterSelection(BOOL bForceDefaults);
- void SaveStdProfileSettings(); // save options to .INI file
- public: // public for implementation access
- CCommandLineInfo* m_pCmdInfo;
- ATOM m_atomApp, m_atomSystemTopic; // for DDE open
- UINT m_nNumPreviewPages; // number of default printed pages
- size_t m_nSafetyPoolSize; // ideal size
- void (AFXAPI* m_lpfnDaoTerm)();
- void DevModeChange(LPTSTR lpDeviceName);
- void SetCurrentHandles();
- int GetOpenDocumentCount();
- // helpers for standard commdlg dialogs
- BOOL DoPromptFileName(CString& fileName, UINT nIDSTitle,
- DWORD lFlags, BOOL bOpenFileDialog, CDocTemplate* pTemplate);
- int DoPrintDialog(CPrintDialog* pPD);
- void EnableModeless(BOOL bEnable); // to disable OLE in-place dialogs
- // overrides for implementation
- virtual BOOL InitInstance();
- virtual int ExitInstance(); // return app exit code
- virtual int Run();
- virtual BOOL OnIdle(LONG lCount); // return TRUE if more idle processing
- virtual LRESULT ProcessWndProcException(CException* e, const MSG* pMsg);
- public:
- virtual ~CWinApp();
- #ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
- #endif
- // helpers for registration
- HKEY GetSectionKey(LPCTSTR lpszSection);
- HKEY GetAppRegistryKey();
- protected:
- //{{AFX_MSG(CWinApp)
- afx_msg void OnAppExit();
- afx_msg void OnUpdateRecentFileMenu(CCmdUI* pCmdUI);
- afx_msg BOOL OnOpenRecentFile(UINT nID);
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
- /////////////////////////////////////////////////////////////////////////////
- // class CWaitCursor
- class CWaitCursor
- {
- // Construction/Destruction
- public:
- CWaitCursor();
- ~CWaitCursor();
- // Operations
- public:
- void Restore();
- };
- /////////////////////////////////////////////////////////////////////////////
- // class CDocTemplate creates documents
- #ifdef _AFXDLL
- class CDocTemplate : public CCmdTarget
- #else
- class AFX_NOVTABLE CDocTemplate : public CCmdTarget
- #endif
- {
- DECLARE_DYNAMIC(CDocTemplate)
- // Constructors
- protected:
- CDocTemplate(UINT nIDResource, CRuntimeClass* pDocClass,
- CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass);
- public:
- virtual void LoadTemplate();
- // Attributes
- public:
- // setup for OLE containers
- void SetContainerInfo(UINT nIDOleInPlaceContainer);
- // setup for OLE servers
- void SetServerInfo(UINT nIDOleEmbedding, UINT nIDOleInPlaceServer = 0,
- CRuntimeClass* pOleFrameClass = NULL, CRuntimeClass* pOleViewClass = NULL);
- // iterating over open documents
- virtual POSITION GetFirstDocPosition() const = 0;
- virtual CDocument* GetNextDoc(POSITION& rPos) const = 0;
- // Operations
- public:
- virtual void AddDocument(CDocument* pDoc); // must override
- virtual void RemoveDocument(CDocument* pDoc); // must override
- enum DocStringIndex
- {
- windowTitle, // default window title
- docName, // user visible name for default document
- fileNewName, // user visible name for FileNew
- // for file based documents:
- filterName, // user visible name for FileOpen
- filterExt, // user visible extension for FileOpen
- // for file based documents with Shell open support:
- regFileTypeId, // REGEDIT visible registered file type identifier
- regFileTypeName, // Shell visible registered file type name
- };
- virtual BOOL GetDocString(CString& rString,
- enum DocStringIndex index) const; // get one of the info strings
- CFrameWnd* CreateOleFrame(CWnd* pParentWnd, CDocument* pDoc,
- BOOL bCreateView);
- // Overridables
- public:
- enum Confidence
- {
- noAttempt,
- maybeAttemptForeign,
- maybeAttemptNative,
- yesAttemptForeign,
- yesAttemptNative,
- yesAlreadyOpen
- };
- virtual Confidence MatchDocType(LPCTSTR lpszPathName,
- CDocument*& rpDocMatch);
- virtual CDocument* CreateNewDocument();
- virtual CFrameWnd* CreateNewFrame(CDocument* pDoc, CFrameWnd* pOther);
- virtual void InitialUpdateFrame(CFrameWnd* pFrame, CDocument* pDoc,
- BOOL bMakeVisible = TRUE);
- virtual BOOL SaveAllModified(); // for all documents
- virtual void CloseAllDocuments(BOOL bEndSession);
- virtual CDocument* OpenDocumentFile(
- LPCTSTR lpszPathName, BOOL bMakeVisible = TRUE) = 0;
- // open named file
- // if lpszPathName == NULL => create new file with this type
- virtual void SetDefaultTitle(CDocument* pDocument) = 0;
- // Implementation
- public:
- BOOL m_bAutoDelete;
- virtual ~CDocTemplate();
- // back pointer to OLE or other server (NULL if none or disabled)
- CObject* m_pAttachedFactory;
- // menu & accelerator resources for in-place container
- HMENU m_hMenuInPlace;
- HACCEL m_hAccelInPlace;
- // menu & accelerator resource for server editing embedding
- HMENU m_hMenuEmbedding;
- HACCEL m_hAccelEmbedding;
- // menu & accelerator resource for server editing in-place
- HMENU m_hMenuInPlaceServer;
- HACCEL m_hAccelInPlaceServer;
- #ifdef _DEBUG
- virtual void Dump(CDumpContext&) const;
- virtual void AssertValid() const;
- #endif
- virtual void OnIdle(); // for all documents
- virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra,
- AFX_CMDHANDLERINFO* pHandlerInfo);
- protected:
- UINT m_nIDResource; // IDR_ for frame/menu/accel as well
- UINT m_nIDServerResource; // IDR_ for OLE inplace frame/menu/accel
- UINT m_nIDEmbeddingResource; // IDR_ for OLE open frame/menu/accel
- UINT m_nIDContainerResource; // IDR_ for container frame/menu/accel
- CRuntimeClass* m_pDocClass; // class for creating new documents
- CRuntimeClass* m_pFrameClass; // class for creating new frames
- CRuntimeClass* m_pViewClass; // class for creating new views
- CRuntimeClass* m_pOleFrameClass; // class for creating in-place frame
- CRuntimeClass* m_pOleViewClass; // class for creating in-place view
- CString m_strDocStrings; // '\n' separated names
- // The document names sub-strings are represented as _one_ string:
- // windowTitle\ndocName\n ... (see DocStringIndex enum)
- };
- // SDI support (1 document only)
- class CSingleDocTemplate : public CDocTemplate
- {
- DECLARE_DYNAMIC(CSingleDocTemplate)
- // Constructors
- public:
- CSingleDocTemplate(UINT nIDResource, CRuntimeClass* pDocClass,
- CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass);
- // Implementation
- public:
- virtual ~CSingleDocTemplate();
- virtual void AddDocument(CDocument* pDoc);
- virtual void RemoveDocument(CDocument* pDoc);
- virtual POSITION GetFirstDocPosition() const;
- virtual CDocument* GetNextDoc(POSITION& rPos) const;
- virtual CDocument* OpenDocumentFile(
- LPCTSTR lpszPathName, BOOL bMakeVisible = TRUE);
- virtual void SetDefaultTitle(CDocument* pDocument);
- #ifdef _DEBUG
- virtual void Dump(CDumpContext&) const;
- virtual void AssertValid() const;
- #endif //_DEBUG
- protected: // standard implementation
- CDocument* m_pOnlyDoc;
- };
- // MDI support (zero or more documents)
- class CMultiDocTemplate : public CDocTemplate
- {
- DECLARE_DYNAMIC(CMultiDocTemplate)
- // Constructors
- public:
- CMultiDocTemplate(UINT nIDResource, CRuntimeClass* pDocClass,
- CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass);
- // Implementation
- public:
- // Menu and accel table for MDI Child windows of this type
- HMENU m_hMenuShared;
- HACCEL m_hAccelTable;
- virtual ~CMultiDocTemplate();
- virtual void LoadTemplate();
- virtual void AddDocument(CDocument* pDoc);
- virtual void RemoveDocument(CDocument* pDoc);
- virtual POSITION GetFirstDocPosition() const;
- virtual CDocument* GetNextDoc(POSITION& rPos) const;
- virtual CDocument* OpenDocumentFile(
- LPCTSTR lpszPathName, BOOL bMakeVisible = TRUE);
- virtual void SetDefaultTitle(CDocument* pDocument);
- #ifdef _DEBUG
- virtual void Dump(CDumpContext&) const;
- virtual void AssertValid() const;
- #endif //_DEBUG
- protected: // standard implementation
- CPtrList m_docList; // open documents of this type
- UINT m_nUntitledCount; // start at 0, for "Document1" title
- };
- /////////////////////////////////////////////////////////////////////////////
- // class CDocument is the main document data abstraction
- #ifdef _AFXDLL
- class CDocument : public CCmdTarget
- #else
- class AFX_NOVTABLE CDocument : public CCmdTarget
- #endif
- {
- DECLARE_DYNAMIC(CDocument)
- public:
- // Constructors
- CDocument();
- // Attributes
- public:
- const CString& GetTitle() const;
- virtual void SetTitle(LPCTSTR lpszTitle);
- const CString& GetPathName() const;
- virtual void SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU = TRUE);
- CDocTemplate* GetDocTemplate() const;
- virtual BOOL IsModified();
- virtual void SetModifiedFlag(BOOL bModified = TRUE);
- // Operations
- void AddView(CView* pView);
- void RemoveView(CView* pView);
- virtual POSITION GetFirstViewPosition() const;
- virtual CView* GetNextView(POSITION& rPosition) const;
- // Update Views (simple update - DAG only)
- void UpdateAllViews(CView* pSender, LPARAM lHint = 0L,
- CObject* pHint = NULL);
- // Overridables
- // Special notifications
- virtual void OnChangedViewList(); // after Add or Remove view
- virtual void DeleteContents(); // delete doc items etc
- // File helpers
- virtual BOOL OnNewDocument();
- virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
- virtual BOOL OnSaveDocument(LPCTSTR lpszPathName);
- virtual void OnCloseDocument();
- virtual void ReportSaveLoadException(LPCTSTR lpszPathName,
- CException* e, BOOL bSaving, UINT nIDPDefault);
- virtual CFile* GetFile(LPCTSTR lpszFileName, UINT nOpenFlags,
- CFileException* pError);
- virtual void ReleaseFile(CFile* pFile, BOOL bAbort);
- // advanced overridables, closing down frame/doc, etc.
- virtual BOOL CanCloseFrame(CFrameWnd* pFrame);
- virtual BOOL SaveModified(); // return TRUE if ok to continue
- virtual void PreCloseFrame(CFrameWnd* pFrame);
- // Implementation
- protected:
- // default implementation
- CString m_strTitle;
- CString m_strPathName;
- CDocTemplate* m_pDocTemplate;
- CPtrList m_viewList; // list of views
- BOOL m_bModified; // changed since last saved
- public:
- BOOL m_bAutoDelete; // TRUE => delete document when no more views
- BOOL m_bEmbedded; // TRUE => document is being created by OLE
- #ifdef _DEBUG
- virtual void Dump(CDumpContext&) const;
- virtual void AssertValid() const;
- #endif //_DEBUG
- virtual ~CDocument();
- // implementation helpers
- virtual BOOL DoSave(LPCTSTR lpszPathName, BOOL bReplace = TRUE);
- virtual BOOL DoFileSave();
- virtual void UpdateFrameCounts();
- void DisconnectViews();
- void SendInitialUpdate();
- // overridables for implementation
- virtual HMENU GetDefaultMenu(); // get menu depending on state
- virtual HACCEL GetDefaultAccelerator();
- virtual void OnIdle();
- virtual void OnFinalRelease();
- virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra,
- AFX_CMDHANDLERINFO* pHandlerInfo);
- friend class CDocTemplate;
- protected:
- // file menu commands
- //{{AFX_MSG(CDocument)
- afx_msg void OnFileClose();
- afx_msg void OnFileSave();
- afx_msg void OnFileSaveAs();
- //}}AFX_MSG
- // mail enabling
- afx_msg void OnFileSendMail();
- afx_msg void OnUpdateFileSendMail(CCmdUI* pCmdUI);
- DECLARE_MESSAGE_MAP()
- };
- /////////////////////////////////////////////////////////////////////////////
- // Extra diagnostic tracing options
- #ifdef _DEBUG
- extern AFX_DATA UINT afxTraceFlags;
- enum AfxTraceFlags
- {
- traceMultiApp = 1, // multi-app debugging
- traceAppMsg = 2, // main message pump trace (includes DDE)
- traceWinMsg = 4, // Windows message tracing
- traceCmdRouting = 8, // Windows command routing trace (set 4+8 for control notifications)
- traceOle = 16, // special OLE callback trace
- traceDatabase = 32, // special database trace
- traceInternet = 64 // special Internet client trace
- };
- #endif // _DEBUG
- //////////////////////////////////////////////////////////////////////////////
- // MessageBox helpers
- void AFXAPI AfxFormatString1(CString& rString, UINT nIDS, LPCTSTR lpsz1);
- void AFXAPI AfxFormatString2(CString& rString, UINT nIDS,
- LPCTSTR lpsz1, LPCTSTR lpsz2);
- int AFXAPI AfxMessageBox(LPCTSTR lpszText, UINT nType = MB_OK,
- UINT nIDHelp = 0);
- int AFXAPI AfxMessageBox(UINT nIDPrompt, UINT nType = MB_OK,
- UINT nIDHelp = (UINT)-1);
- // Implementation string helpers
- void AFXAPI AfxFormatStrings(CString& rString, UINT nIDS,
- LPCTSTR const* rglpsz, int nString);
- void AFXAPI AfxFormatStrings(CString& rString, LPCTSTR lpszFormat,
- LPCTSTR const* rglpsz, int nString);
- BOOL AFXAPI AfxExtractSubString(CString& rString, LPCTSTR lpszFullString,
- int iSubString, TCHAR chSep = '\n');
- /////////////////////////////////////////////////////////////////////////////
- // Special target variant APIs
- #ifdef _AFXDLL
- #include <afxdll_.h>
- #endif
- // Windows Version compatibility (obsolete)
- #define AfxEnableWin30Compatibility()
- #define AfxEnableWin31Compatibility()
- #define AfxEnableWin40Compatibility()
- // Temporary map management (locks temp map on current thread)
- void AFXAPI AfxLockTempMaps();
- BOOL AFXAPI AfxUnlockTempMaps(BOOL bDeleteTemps = TRUE);
- /////////////////////////////////////////////////////////////////////////////
- // Special OLE related functions (see OLELOCK.CPP)
- void AFXAPI AfxOleOnReleaseAllObjects();
- BOOL AFXAPI AfxOleCanExitApp();
- void AFXAPI AfxOleLockApp();
- void AFXAPI AfxOleUnlockApp();
- void AFXAPI AfxOleSetUserCtrl(BOOL bUserCtrl);
- BOOL AFXAPI AfxOleGetUserCtrl();
- #ifndef _AFX_NO_OCC_SUPPORT
- BOOL AFXAPI AfxOleLockControl(REFCLSID clsid);
- BOOL AFXAPI AfxOleUnlockControl(REFCLSID clsid);
- BOOL AFXAPI AfxOleLockControl(LPCTSTR lpszProgID);
- BOOL AFXAPI AfxOleUnlockControl(LPCTSTR lpszProgID);
- void AFXAPI AfxOleUnlockAllControls();
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // Use version 1.0 of the RichEdit control
- #define _RICHEDIT_VER 0x0100
- /////////////////////////////////////////////////////////////////////////////
- // Inline function declarations
- #ifdef _AFX_PACKING
- #pragma pack(pop)
- #endif
- #ifdef _AFX_ENABLE_INLINES
- #define _AFXWIN_INLINE AFX_INLINE
- #include <afxwin1.inl>
- #include <afxwin2.inl>
- #endif
- #undef AFX_DATA
- #define AFX_DATA
- #ifdef _AFX_MINREBUILD
- #pragma component(minrebuild, on)
- #endif
- #ifndef _AFX_FULLTYPEINFO
- #pragma component(mintypeinfo, off)
- #endif
- /////////////////////////////////////////////////////////////////////////////
- #else //RC_INVOKED
- #include <afxres.h> // standard resource IDs
- #endif //RC_INVOKED
- #endif //__AFXWIN_H__
- /////////////////////////////////////////////////////////////////////////////
|