A.D.Tejpal
adtp at airtelbroadband.in
Mon Dec 17 11:59:40 CST 2007
Gustav, Thanks for kindly providing a sample utilization of WithEvents approach for setting focus & highlighting of text boxes on mouse move. I tested your code over the week-end and it does perform as indicated. It is a fascinating technique and it was your post that prompted me to actually try it out. Really nice of you. Coming to the topic covered by current thread, let us consider a more elaborate set of objectives as outlined below: 1 - A form has multiple controls (text / combo boxes & labels) in all its sections (Header / Detail / Footer). 2 - Controls with transparent BackStyle should remain exempt from highlighting effected by MouseMove. 3 - Mere MouseMove should not cause focus to be set on text / combo boxes. Setting focus on a particular control should be through conscious user action, either by mouse click or by tabbing into it. 4 - At any given stage, a maximum of two controls can simultaneously be in highlighted state, namely the control (text or combo box) having actual focus and the control (text / combo box or label) having mouse over it. Control having focus should get highlighted in a distinct color that is different from the highlight color induced by MouseMove. GotFocus highlight should supersede any intended highlighting resulting from MouseMove. 5 - As a corollary to item 4 above, while a text / combo box not having focus is in highlighted state caused by mouse move, and subsequently the focus shifts to this control, its color will change to that pertaining to GotFocus. 6 - As soon as a control has neither focus nor mouse over it, its back color and special effect should revert to the original status. 7 - On MouseMove, the response should be as follows: (a) Text & combo boxes should get highlighted in a distinct color, different from that signifying GotFocus - (No automatic focus merely due to MouseMove). At the same time the control should acquire Raised as the special effect. (b) Labels should get highlighted in a distinct color - (This color should be different from that for text / combo boxes GotFocus or MouseMove status). At the same time the control should acquire Raised as the special effect. My sample db named Form_CommonMouseMoveFunction, demonstrating successful compliance with all the above objectives, has been uploaded to Rogers Access Library. Link: http://www.rogersaccesslibrary.com/OtherLibraries.asp#Tejpal,A.D. In its present version, the sample represents a class-less solution. However, it would be nice if we could add an alternative solution, for similar objectives, based upon WithEvents approach so as to present a ready comparison side by side. Prima facie, it would appear that multiple sets of classes might be needed for the three control types (text, combo, label). If you find it convenient, could you please have a look at the sample db and examine as to what could be the simplest possible solution based upon WithEvents, providing equivalent performance. Another aspect that needs examination is that for a solution not dependent upon mouse x & y, Access application's built in feature, allowing assignment of functions (with arguments) against OnMouseMove property of a control enables you to use an already sunk-in event rather than first sinking it all over again and then using it. Of course the latter course of action would have been unavoidable, if [Event Procedure] were the only property allowed. Lambert: Thanks for your kind input. The point raised by you was well taken and has been addressed in the sample db mentioned above. Susan: If you are still pursuing the subject, sample db mentioned above, might be of interest. Best wishes, A.D.Tejpal ------------ ----- Original Message ----- From: Gustav Brock To: accessd at databaseadvisors.com Sent: Wednesday, December 12, 2007 16:56 Subject: Re: [AccessD] events question Hi AD and Susan But this is just so much easier to achieve using WithEvents. Shamil told me once how to do it, and this method is much more flexible and powerful. And everyone who can create a code module can join the game! A real eye-opener if WithEvents is new to you. For your convenience, I have pasted three textfiles you can load into an empty database with these three commands in the imm. window to create a working demo in one minute: LoadFromText acModule, "CTxtHighlight", "d:\path\CTxtHighlight.txt" LoadFromText acModule, "CTxtMouseMove", "d:\path\CTxtMouseMove.txt" LoadFromText acForm, "frmMouseHighlightTest", "d:\path\frmMouseHighlightTest.txt" where you, of course, will have to adjust "d:\path" to your location of the files. Compile and save all modules, open the form and voila! Note that MouseMove controls the focus, while the focus controls the back colour. /gustav