11.07.2015 Views

101 Tech Tips - Visual Studio Magazine - One-Stop Source Shop

101 Tech Tips - Visual Studio Magazine - One-Stop Source Shop

101 Tech Tips - Visual Studio Magazine - One-Stop Source Shop

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>101</strong> TECH TIPSFor <strong>Visual</strong> <strong>Studio</strong> DevelopersShift As Integer, X As Single, Y As Single)If Button = vbLeftButton ThenWith shpRectangle.Visible = False 'reduces flickeringmlBottom = YmlRight = X' Don't allow clip to include non-picture' regionIf mlBottom > pic.Height Then _mlBottom = pic.HeightIf mlRight > pic.Width Then _mlRight = pic.WidthIf mlBottom < pic.Top Then _mlBottom = pic.TopIf mlRight < pic.Left Then _mlRight = pic.Left' Swap top/bottom as necessaryIf mlBottom < mlTop Then.Top = mlBottom.Height = mlTop - mlBottomElse.Top = mlTop.Height = mlBottom - mlTopEnd If' Swap left/right as necessaryIf mlRight < mlLeft Then.Left = mlRight.Width = mlLeft - mlRightElse.Left = mlLeft.Width = mlRight - mlLeftEnd If.Visible = TrueDoEvents ' Allow rectangle to drawfrmClip.PaintPicture pic.Picture, 0, 0, _frmClip.ScaleWidth, _frmClip.ScaleHeight, _.Left - pic.Left, .Top - pic.Top, _.Width, .HeightEnd WithEnd IfEnd SubPrivate Sub pic_MouseDown(Button As Integer, _Shift As Integer, X As Single, Y As Single)If Button = vbLeftButton ThenmlTop = YmlLeft = XEnd IfEnd SubPrivate Sub pic_MouseUp(Button As Integer, _Shift As Integer, X As Single, Y As Single)shpRectangle.Visible = FalseEnd Sub—Graeme Anderson, Blackburn, AustraliaVB5, VB6Level: IntermediateMerge VBL Files Into Your RegistryUse this tip when developing ActiveX components and testingActiveX OCXs that require license files. These Registry entriesallow you to merge VBL file contents into the Registry. You addthree context menu options for VBL files: Merge (into the Registry),Edit, and Print:REGEDIT4[HKEY_CLASSES_ROOT\.vbl]@="<strong>Visual</strong>Basic.VBLFile"[HKEY_CLASSES_ROOT\<strong>Visual</strong>Basic.VBLFile]@="<strong>Visual</strong> Basic Control License File"[HKEY_CLASSES_ROOT\<strong>Visual</strong>Basic.VBLFile\DefaultIcon]@="NOTEPAD.EXE,1"[HKEY_CLASSES_ROOT\<strong>Visual</strong>Basic.VBLFile\shell][HKEY_CLASSES_ROOT\<strong>Visual</strong>Basic.VBLFile\shell\edit]@="&Edit"[HKEY_CLASSES_ROOT\<strong>Visual</strong>Basic.VBLFile\shell\edit\command]@="NOTEPAD.EXE \"%1\""[HKEY_CLASSES_ROOT\<strong>Visual</strong>Basic.VBLFile\shell\open]@="Mer&ge"[HKEY_CLASSES_ROOT\<strong>Visual</strong>Basic.VBLFile\shell\open\command]@="regedit.exe \"%1\""[HKEY_CLASSES_ROOT\<strong>Visual</strong>Basic.VBLFile\shell\print][HKEY_CLASSES_ROOT\<strong>Visual</strong>Basic.VBLFile\shell\print\command]@="NOTEPAD.EXE /P \"%1\""Editor’s Note: All the usual warnings apply, of course, when runningscripts against your Registry.VB4, VB5, VB6Level: Beginning—Tom Sweet, Marietta, Ga.Use the Keyboard for Extra-Fine Sizing andPositioningIf you have a sensitive mouse and/or many objects you need toposition carefully on a form, getting everything right can be a realpain—especially when you click on an object simply to alter someof its properties and move it accidentally. Here’s the answer: Usethe “Lock Controls” option under the Format menu to lock theposition of a form’s controls so you can’t change control positionsaccidentally when clicking on the controls. But now you can’t usethe mouse to reposition a control without unlocking everything.However, you can use the keyboard. Simply select the controlwhose position you want to change and combine the Ctrl key andarrow keys to move the control, or the Shift key and arrow keys toresize it. The grid spacing you’ve configured (Tools | Options |General) controls the move/size extent per arrow press.—John Cullen, Pedroucos, Portugal16 Supplement to <strong>Visual</strong> <strong>Studio</strong> <strong>Magazine</strong> SEPTEMBER 2001

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!