![]() ![]() To execute this command, you have to run command prompt as administrator. Note that you have to free the objects you saved into button's tag when the buttons are freed (unless the buttons are not freed until app terminates, then you don't have to worry about it althought it isn't good style).Many users are familiar with the sfc / scannow system file integrity check command, which automatically checks and fixes protected Windows system files. Procedure TForm3.DeleteAppButton(aBtn: TSpeedButton) ![]() Procedure TForm3.btnMouseDown(Sender: TObject Button: TMouseButton Shift: TShiftState X, Y: Integer) ĪppData := TAppDetails((Sender as TSpeedButton).Tag) The Sender of the event is the button, so save the "appData" into button's tag (when you create it) and then in the mouse event use it, ie procedure TForm3.CreateAppButton(sBtnCapt: string) This idea can easily be extended to include as much information as you like in the TAppPaths record.Īs an aside, I think you should be handling MouseUp rather than MouseDown since in Windows, buttons are clicked when you release the mouse button rather than when you press it. ![]() Then in the form's mouse event handler you write it like this: AppPaths := ButtonDetails Īnd now AppPaths has both paths ready for you to use. When ever you add a new button you write code like this: AppPaths.Left := AppDetails.Exe ĪppPaths.Right := AppDetails.SomeOtherFunction TAppPaths= recordįor sake of argument, let us suppose that this instance is called ButtonDetails. Here I'm imagining that TAppPaths is a record containing two strings, one for the left click and one for the right click, e.g. I think I would use an instance of TDictionary to map between buttons and the application details. I am also somewhat dubious of solutions that use Tag. Not least because you may at some point in time wish to use the Hint property for something else. I agree that you should not use the Hint property. ShellExecute(self.Handle, 'open', PChar(AppData.Wiki), nil, nil, SW_SHOWNORMAL) Ĭan anyone point me in a direction to dynamically use the mousedown event without declaring the component ahead of time? Appdata is a separate pas file containing all the needed information on each application in case anyone is wondering.Īlso please forgive my rather horrendous code, I know it could use a lot of work. ShellExecute(self.Handle, 'open', PChar(sApp), nil, nil, SW_SHOWNORMAL) procedure TForm3.btnMouseDown(Sender: TObject Button: TMouseButton Shift: TShiftState Designing the right click way would require me to put in ~80 it also requires that I declare each button on the form so that I can build and compile. You can see what I am trying to in the left click and where I am coming from in the right click. I want to somehow use the information stored in the buttons hint property to trigger the needed action. Where my issue arises is on the mouse down event. If PrivateExtractIcons(PChar(sPathNew), 0, 16, 16, 1, LR_LOADFROMFILE) extract a 16x16 icon for display on the buttom ![]() Left := (Width + 5) * (self.ControlCount - 1) procedure TForm3.CreateAppButton(sBtnCapt: string) I am storing a piece of needed information in the buttons hint. I am dynamically creating buttons from an array that is dynamically loaded. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |