What we need to do is link Image1’s MouseWheel event handler to ComboBox1’s Change event handler.
Select Image1 either on the form or in the Object Inspector.
Click on the Events tab in the Object inspector and then click OnMouseWheel.
Click on the 3 dot button to create the empty method.
Add the following code to the method.
procedure TForm1.Image1MouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); var i: integer; begin with ComboBox1 do begin //Worth it? if Items.Count=0 then exit; i := ItemIndex; //Change according to direction if (WheelDelta>0) then i := i - 1 else i := i + 1; //Check range if i < 0 then i := 0 else if i >= Items.Count then i := Items.Count - 1; //Any change? if i <> ItemIndex then begin //Apply it ItemIndex := i; //Fire OnChange if assigned(OnChange) then OnChange(Sender); end; end; end;
Build and run the program and open a *.wad file and point the mouse over Image1.
Use the mouse wheel to “scroll” through the pages.
In the previous post I forgot to set ComboBox1 as read only so we will fix that now.
Click on ComboBox1 in the Object Inspector and click on the ReadOnly property and change it to True in the dropdown and then save the project.
If you click on a texture map page in StrPix or PixStr or TextureAdd or WadExplorer, if a texture exists under the mouse pointer, it is highlighted by surrounding it with a coloured rectangle.
The texture information is stored as a list of texinfos in the variable wad.textureTableData.
A texinfo defines a rectangle in a texture map page.
In the next post we will link the position of the mouse pointer when the mouse is clicked on Image1 to a texinfo in wad.textureTableData and highlight that rectangle in the texture map.
prev | next
No comments:
Post a Comment