Jump to content

Razraal

Members
  • Posts

    18
  • Joined

  • Last visited

Everything posted by Razraal

  1. @BrewManNH what styles must I use to make a new GUI look like a button (no top bar, no borders, etc.)
  2. Hey there! Task: Drag and drop a control (in this case, either a button or a pic), possibly OUT of the current GUI. I have this test code: HotKeySet("{ESC}", "exit_program") Func exit_program() Exit EndFunc Func testButton() Local $x, $y GUICreate("my Window", 350, 150) GUISetState(@SW_SHOW) Local $button = GUICtrlCreateButton("boink", 10, 50, 40, 40) While True $x = MouseGetPos(0) $y = MouseGetPos(1) If(GUIGetMsg() = $button) Then ;... EndIf WEnd EndFunc testButton() I want to be able to move the boink button anywhere I want in my screen, even out of my current (and only) GUI. I know how to detect a drag, but about controls' position I only found GUICtrlSetPos() which defines a position for the control within the GUI. How can I achieve my task? Cheers!
  3. Up until now, doing the write task is solved. However, doing the read task is troublesome: $file = FileOpen("myfile") $var = FileRead($file) ;This is now the stream of bytes that were stored Now I need to divide my $var into chunks of bytes and convert bytes into the specific things I need (ints, strings, booleans, arrays), according to the struct. In the case of the example struct I posted above, how would I do that?
  4. @jchd, from what I understood: For every DllStruct of mine (that is, for every element in my array of DllStructs), I create another DllStruct which has the same byte length and content of the original DllStruct. Afterwards I write it to a file which was opened with the flags $FO_OVERWRITE+$FO_BINARY. Is that it? Also, from what I understood of your code: Local $s1 = DllStructCreate("align 1;byte;short;byte;real;align 2;byte[3];align 1; byte[7]") I'm assuming this is merely an example, and thus the DllStruct's content is irrelevant. In the test I'm doing, I used: Global $var = DllStructCreate("struct;char name[10];int age;bool isMale;endstruct") Since I used "struct"&"endstruct" to make a C like struct, from what I read this does implicit structure alignments. Local $bs1 = DllStructCreate("byte[" & DllStructGetSize($s1) & "]", DllStructGetPtr($s1)) ; now $bs1 is a "flat" binary piece located at the same address as $s1 This looks like a wrapper to me. You're creating a DllStruct with a byte[] array long enough to contain the previous DllStruct. You also give the function a pointer, hence the comment. Local $h = FileOpen("MyStruct.bin", $FO_OVERWRITE + $FO_BINARY) FileWrite($h, DllStructGetData($bs1)) From what I see, instead of passing the variable $bs1, you passed its data. Why was that? By the way, DllStructGetData needs a second parameter, 1. DllStructGetData($bs1, 1)
  5. Update: I've been meddling with the functions I listed before. Creating a file and writing text into was a straightforward task: _FileCreate("jinx") $file = FileOpen("jinx", $FO_APPEND) FileWrite($file, "my jinx are tight!") FileClose($file) I then tried writing data in binary format into my file: Global $bin = Binary($var) _FileCreate("jinx") $file = FileOpen("jinx", $FO_BINARY) FileWrite($file, $bin) FileClose($file) Note that $var was previously created with DllStructCreate() This binary writing proved unsuccessful. Is there anything I'm missing in the second code?
  6. Hey there folks! Task: I have an array of DllStructs, created with the function DllStructCreate. Let's call the array $structs. This $structs contains important information for the program. I want to save my $structs variable for future use in a file (i.e.: the user closes the program, opens it again and has the option to load a file). I want to load files which contain a $structs variable, and let the program work with this "loaded" variable. Questions: Since I have never done such a thing (saving/loading a file, possibly in a different format from txt or ini), I'd like to know: Is this possible? Is my only option to save my $structs in text format? That would require a function which receives a file and interprets the text it has, creating a new $structs with the info it's getting from the file. (I think this could lead to trouble) I'm worried about security. Since the program will be loading files, I don't want it to crash because the user decided to give it modified files. Is it possible to create a file that's readonly for the user? That would prevent some tampering with the file. From what I've been reading, I have several functions available for File management, namely FileOpen, FileRead and FileWrite. In a first glance, these appear to be the only functions I need. Do I need more? Thank you for your time! Cheers!
  7. @AutoBert You mean the 220 lines of code "simple" example? This isn't the answer I'm looking for. It takes a lot of time to read all those lines and correctly interpret them. Whereas if you have the knowledge on how to proceed to make it a working scrollbar, you save me time (and this becomes a visible and simpler solution for everyone to check).
  8. Hey there folks! I've been looking through the scrollbar functions, there are many and seem endless. I need to implement a vertical scrollbar for my GUI - its content will increase downwards over time and I need a scrollbar to be able to check it all. So far I've used the functions _GUIScrollBars_Init and _GUIScrollBars_ShowScrollBar. This created and made visible my vertical scrollbar, but it does nothing. How do I proceed to make it a working scrollbar?
  9. I managed to achieve what I wanted using _IsPressed function.
  10. By the way @InunoTaishou thanks for the _IsPressed tip!
  11. The existance of a "simpler/better" solution is irrelevant: if we contour the problem by reshaping it into a different one, we're not solving the original one. Problem: I want my program to be able to detect a single left click even when the current and only active GUI has no focus. Sequence of actions: I have a GUI, with focus; I click outside the GUI; Desired action: The click is detected. What happens first: the GUI losing focus or the click being detected? How can I solve this?
  12. Sure thing Melba!
  13. Hey there folks. Task: I want to detect a click (preferably outside the current GUI), however I'm being unable to do so. I've been struggling with this issue for a few hours, so I decided to test it apart from my project, and coded this piece of program: (all the necessary includes) HotKeySet("{ESC}", "exit_program") Func exit_program() Exit EndFunc GUICreate("fu*** sake", 100, 100) GUISetState(@SW_SHOW) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_PRIMARYUP ConsoleWrite("lol"&@LF) EndSwitch WEnd Supposedly I should detect a click with the event $GUI_EVENT_PRIMARYUP (releasing the left button). Problem is it only detects when I click inside my GUI. When I do it outside, the program loses focus and this in turn keeps it from functioning properly (maybe it starts idling for CPU economy, who knows). The most direct solution I thought about was being able to make the GUI always active. However I have no idea how. Any solutions you might think of? Cheers!
  14. Thanks for your help mate, I appreciate it! I've decided to create an image control with GUICtrlCreateImage, instead of a button with an image, since the overal result is almost the same.
  15. Hey there @Melba23, thanks for the welcoming! I've tried with a bmp image, also does not work. $button = GUICtrlCreateButton ("", 10, 10, 40, 40, $BS_BITMAP) GUICtrlSetImage ($button, "my_image.bmp") Converted the original jpg image through GIMP to a bmp image. Same resolution. Same result.
  16. Additional info: Added the $BS_BITMAP style to the GUICtrlCreateButton. $button = GUICtrlCreateButton ("", 10, 10, 40, 40, $BS_BITMAP) GUICtrlSetImage ($button, "my_image.jpg") Still fails to show the image.
  17. Additional info: The "my_image.jpg" file is a 1024x1024 picture.
  18. Hey there. I want to create a button with an image. So far I've been unable to do it. Here's the code that creates the button and sets the image: $button = GUICtrlCreateButton ("", 10, 10, 40, 40) GUICtrlSetImage ($button, "my_image.jpg") Is there any other step I need to do?
×
×
  • Create New...