Jump to content

imagebox not displaying


nordi

Recommended Posts

Hey

 

So I'm trying to display imagebox, but i can't get it working, they do not appear on the screen.

the picture (menu.png) is set as embedded ressource for the compilation, so the problem isn't because of that.

Edited by nordi
Link to comment
Share on other sites

im not sure about this but, if im not wrong, you need a form as Parent for this image object, im not sure but based on my short tests with labels and listbox i walways needed a form to put the objects "inside" (parent)

Edited by julionib
Link to comment
Share on other sites

im not sure about this but, if im not wrong, you need a form as Parent for this image object, im not sure but based on my short tests with labels and listbox i walways needed a form to put the objects "inside" (parent)

 

Correct, it's working now.

Link to comment
Share on other sites

im not sure about this but, if im not wrong, you need a form as Parent for this image object, im not sure but based on my short tests with labels and listbox i walways needed a form to put the objects "inside" (parent)

 

How can I hide the title of the form ?

 

My Mousedown event, do not work: I click on the imagebox, but nothing happens (no error, no text displaying, no object spawned):

Thanks.

Edited by nordi
Link to comment
Share on other sites

set title size to 0, then you need to set mouse.enable = false + form.visible = false when hiding the form, if im not wrong

Link to comment
Share on other sites

set title size to 0, then you need to set mouse.enable = false + form.visible = false when hiding the form, if im not wrong

 

But the MouseDown event, still don't work :/

Edited by nordi
Link to comment
Share on other sites

set title size to 0, then you need to set mouse.enable = false + form.visible = false when hiding the form, if im not wrong

 

One last question, I decided to use the keyboard (Arrow, and enter key) instead of the Mouse, to select the imagebox. But, the problem is that, the key pressed are ignored when the form is active. How can I fix this issue ?

I already have a KeyHandler function, and inside this KeyHandler, i create the form when T is pressed, and when the form is active (checked with a bool) I run new functions when the arrow are pressed.

Edited by nordi
Link to comment
Share on other sites

i found same issue, seems that when we create the Form only text fields in Form will be enabled, keypress dont go to game, so, they don't go to the normal events in scripthook. At this moment i left the Form idea behind and still using my old menu method that is basically draw all you need on screen using draw_xxxxxx and print_string_xxxxxxx methods

in ironman IV and V Style i did similar thing that you want do in this mod, but i used external images and PerFramedrawing event to draw them, then used mouse.movementpixel to calculate the heading of the mouse (screen center is the base), based on that heading i know if its on the range of one of the options, also used this idea in Radio V Style

Link to comment
Share on other sites

pedro2555

 

set title size to 0, then you need to set mouse.enable = false + form.visible = false when hiding the form, if im not wrong

 

One last question, I decided to use the keyboard (Arrow, and enter key) instead of the Mouse, to select the imagebox. But, the problem is that, the key pressed are ignored when the form is active. How can I fix this issue ?

I already have a KeyHandler function, and inside this KeyHandler, i create the form when T is pressed, and when the form is active (checked with a bool) I run new functions when the arrow are pressed.

 

 

I might be missing something here, I've used GTA.Forms once only.

 

But why aren't you doing the normal process for forms usage, like you do in Windows.Forms?

 

Like have a main container, the form itself, and inside it have all the it's controls responsible for interacting with the user. GTA.Forms provides the main controls, but you can always develop you own. Just like Windows.Forms. Here is the function separation of .NET Form Controls and there intended usage.

 

 

--------- Text edit ---------
TextBox
Allows editable, multiline input from the user.
ToolStripTextBox
Allows editable, multiline input from the user.
RichTextBox
Allows users to enter, display, and manipulate text with formatting.
--------- Text display (read-only) ---------
Label
Displays text that cannot be edited by the user.
ToolStripLabel
Displays text that cannot be edited by the user.
LinkLabel
Allows you to add Web-style links to Windows Forms applications.
StatusBar
Displays status information related to the control that has focus.
ToolStripStatusLabel
Displays status information related to the control that has focus.
--------- Selection from a list ---------
CheckedListBox
Displays a list of items with a check box next to each item.
ComboBox
Displays data in a drop-down combo box.
ToolStripComboBox
Displays data in a drop-down combo box.
DomainUpDown
Displays text strings that a user can browse through and select from.
ListBox
Displays a list of text and graphical items (icons).
ListView
Displays a list of items with icons, in the manner of Windows Explorer.
NumericUpDown
Displays numerals that a user can browse through and select from.
TreeView
Displays a hierarchy of nodes that can be expanded or collapsed.
--------- Graphics display ---------
PictureBox
Displays graphics in bitmap, GIF, JPEG, metafile, or icon format.
--------- Graphics storage ---------
ImageList
Displays images on other controls.
--------- Value setting ---------
CheckBox
Indicates whether a condition is on or off.
CheckedListBox
Displays a list of items with a check box next to each item.
RadioButton
Presents a set of two or more mutually exclusive options to the user.
TrackBar
Allows navigation through a large amount of information or visually adjusting a numeric setting.
--------- Date setting ---------
DateTimePicker
Allows the user to select a single item from a list of dates or times.
MonthCalendar
Presents an intuitive graphical interface for users to view and set date information.
--------- Dialog boxes ---------
ColorDialog
Allows the user to select a color from a palette in a pre-configured dialog box and to add custom colors to that palette.
FolderBrowserDialog
Displays an interface with which users can browse and select a directory or create a new one.
FontDialog
Exposes the fonts that are currently installed on the system.
OpenFileDialog
Allows users to open files via a pre-configured dialog box.
PageSetupDialog
Sets page details for printing via a pre-configured dialog box.
PrintDialog
Selects a printer, chooses the pages to print, and determines other print-related settings.
PrintDocument
Sets the properties that describe what to print, and prints the document in Windows-based applications.
PrintPreviewControl
Allows you to create your own PrintPreview component or dialog box instead of using the pre-configured version.
PrintPreviewDialog
Displays a document as it will appear when it is printed.
SaveFileDialog
Selects files to save and where to save them.
--------- Menu controls ---------
MainMenu
Displays a menu at run time.
MenuStrip
Displays a menu at run time.
ContextMenu
Provides users with an easily accessible menu of frequently used commands that are associated with the selected object.
ContextMenuStrip
Provides users with an easily accessible menu of frequently used commands that are associated with the selected object.
--------- Commands ---------
Button
Presents a standard button that the user can click to perform actions.
LinkLabel
Allows you to add Web-style links to Windows Forms applications.
NotifyIcon
Displays icons for processes that run in the background and would not otherwise have user interfaces.
ToolBar
Displays menus and bitmapped buttons that activate commands.
ToolStrip
Lets you create custom toolbars and menus in your Windows Forms applications.
--------- Grouping other controls ---------
Panel
Provides an identifiable grouping for other controls, and allows for scrolling.
GroupBox
Provides an identifiable grouping for other controls.
TabControl
Displays multiple tabs that can contain pictures or other controls.
--------- Data ---------
DataGrid
Displays tabular data from a dataset and allows for updates to the data source.
DataGridView
Provides a user interface to ADO.NET datasets, displaying tabular data and allowing for updates to the data source.
--------- Navigation ---------
HScrollBar
Provides navigation through a list of items or a large amount of information by scrolling horizontally within an application or control.
VScrollBar
Provides navigation through a list of items or a large amount of information by scrolling vertically within an application or control.
--------- User information ---------
ErrorProvider
Displays error information to the user in a non-intrusive way.
HelpProvider
Associates an HTML Help file with a Windows-based application.
--------- Web ---------
WebBrowser
Hosts Web pages and provides Internet Web browsing capabilities to your application.
--------- Multitasking ---------
BackgroundWorker
Allows you to run time-consuming operations in the background, on a thread different from your application's main UI thread.
--------- User interface aids ---------
ProgressBar
Graphically indicates the progress of an action towards completion.
ToolStripProgressBar
Graphically indicates the progress of an action towards completion.
SplitContainer
Allows the user to resize a docked control.
Timer
Raises an event at regular intervals.
ToolTip
Displays text when the user points at other controls.
Reading this you should use a button, rather than an imageBox, because button implements button events.
Edited by pedro2555
Link to comment
Share on other sites

LordOfTheBongs

i found same issue, seems that when we create the Form only text fields in Form will be enabled, keypress dont go to game, so, they don't go to the normal events in scripthook. At this moment i left the Form idea behind and still using my old menu method that is basically draw all you need on screen using draw_xxxxxx and print_string_xxxxxxx methods

 

in ironman IV and V Style i did similar thing that you want do in this mod, but i used external images and PerFramedrawing event to draw them, then used mouse.movementpixel to calculate the heading of the mouse (screen center is the base), based on that heading i know if its on the range of one of the options, also used this idea in Radio V Style

yeah which is why i never use Forms... PerFrameDraw is the best way, and u can even disable controls yourself if u wanted to... just way more control with perframedraw. I guess the only benefit of forms is u get a mouse pointer...

 

but anyways in the Script class there is an internal method ProcessEvents() and it blocks handling keydown event when there is any form open...

 

Ef4rOy7.png

Edited by LordOfTheBongs
Link to comment
Share on other sites

 

 

set title size to 0, then you need to set mouse.enable = false + form.visible = false when hiding the form, if im not wrong

 

One last question, I decided to use the keyboard (Arrow, and enter key) instead of the Mouse, to select the imagebox. But, the problem is that, the key pressed are ignored when the form is active. How can I fix this issue ?

I already have a KeyHandler function, and inside this KeyHandler, i create the form when T is pressed, and when the form is active (checked with a bool) I run new functions when the arrow are pressed.

 

 

I might be missing something here, I've used GTA.Forms once only.

 

But why aren't you doing the normal process for forms usage, like you do in Windows.Forms?

 

Like have a main container, the form itself, and inside it have all the it's controls responsible for interacting with the user. GTA.Forms provides the main controls, but you can always develop you own. Just like Windows.Forms. Here is the function separation of .NET Form Controls and there intended usage.

Reading this you should use a button, rather than an imageBox, because button implements button events.

 

 

Well, I prefer to use the Script class, when they are available, and Picturebox (ImageBox) seems to be the better choice for the menu i'm making, plus obviously as stated above, whenever a form is open, Keypress won't work, so it do not fix the problem ;)

 

 

i found same issue, seems that when we create the Form only text fields in Form will be enabled, keypress dont go to game, so, they don't go to the normal events in scripthook. At this moment i left the Form idea behind and still using my old menu method that is basically draw all you need on screen using draw_xxxxxx and print_string_xxxxxxx methods

 

in ironman IV and V Style i did similar thing that you want do in this mod, but i used external images and PerFramedrawing event to draw them, then used mouse.movementpixel to calculate the heading of the mouse (screen center is the base), based on that heading i know if its on the range of one of the options, also used this idea in Radio V Style

yeah which is why i never use Forms... PerFrameDraw is the best way, and u can even disable controls yourself if u wanted to... just way more control with perframedraw. I guess the only benefit of forms is u get a mouse pointer...

 

but anyways in the Script class there is an internal method ProcessEvents() and it blocks handling keydown event when there is any form open...

 

 

They should have give us the choice, to decide if whether or not KeyDown should be checked or not when a form is open, on the argument when calling the KeyDown event, but hey: let's not complain, and be thankful for what we have: it's better than nothing (plus, we have other way to achieve it)

 

 

 

 

i found same issue, seems that when we create the Form only text fields in Form will be enabled, keypress dont go to game, so, they don't go to the normal events in scripthook. At this moment i left the Form idea behind and still using my old menu method that is basically draw all you need on screen using draw_xxxxxx and print_string_xxxxxxx methods

 

in ironman IV and V Style i did similar thing that you want do in this mod, but i used external images and PerFramedrawing event to draw them, then used mouse.movementpixel to calculate the heading of the mouse (screen center is the base), based on that heading i know if its on the range of one of the options, also used this idea in Radio V Style

 

Alright, will try.

Edited by nordi
Link to comment
Share on other sites

LordOfTheBongs

he probably prevented because maybe there is conflict when processing both but yeah there is perframe draw and u just make your own forms

Link to comment
Share on other sites

pedro2555

All GTA.Forms controls are based on Windows.Forms controls, so they implement both keyUp and keyDown events, and they do work! I've just tested. But as with Windows.Forms controls, they implement the concept of Focus, and you can only catch keyboard/mouse events on a focused control, naturally when using the mouse, the click and focus occur with the same user action.

 

 

What's missing is the Focus() method.

Link to comment
Share on other sites

All GTA.Forms controls are based on Windows.Forms controls, so they implement both keyUp and keyDown events, and they do work! I've just tested. But as with Windows.Forms controls, they implement the concept of Focus, and you can only catch keyboard/mouse events on a focused control, naturally when using the mouse, the click and focus occur with the same user action.

 

 

What's missing is the Focus() method.

 

Well, I already have finish rewriting the whole thing, to have the menu working using perframe draw (and it's working by the way), but this is good to know if I ever need to create another menu ! thanks for sharing !

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.