IonicWind Software

IWBasic => General Questions => Topic started by: Andy on April 24, 2016, 11:35:16 PM

Title: Controls and key press
Post by: Andy on April 24, 2016, 11:35:16 PM

I'm looking to improve the editor for binary values.

I am experimenting with a line of small edit boxes and I want to know which edit box has the focus and detect the delete button being pressed at the same time.

I can detect the edit control id (which control is being edited), and I can detect when the Delete button is pressed, but not both at the same time.

So, if an edit box has the focus, how can I detect if the delete button has just been pressed?

Does anyone know how to do this?

Thanks,
Andy.
Title: Re: Controls and key press
Post by: LarryMc on April 25, 2016, 01:29:18 AM
you can always catch a button press with this structure in the parent window/dialog handler


case @IDCONTROL
select @CONTROLID
case button1
IF @NOTIFYCODE=0
'button pressed
ENDIF
endselect


Title: Re: Controls and key press
Post by: LarryMc on April 25, 2016, 01:32:19 AM
or do  you mean the Del key?
Title: Re: Controls and key press
Post by: Andy on April 25, 2016, 01:50:56 AM

Larry, thanks for that, but I am looking for the Del key press.

Title: Re: Controls and key press
Post by: Egil on April 25, 2016, 02:42:04 AM
In my antenna calculators I use this code to see if a particular key is pressed:

case @idkeydown
if GETKEYSTATE(0x2E) <> 0 then  .....          ' If Del-key is pressed, do whatever you want.code]


If you combine this with a test to determine what control has focus at the moment, you should be able to produce very useful code.

The ASCII codes representing the keys can be found in the User Guide Appendix section.


Good luck!


EDIT: I had a feeling that something was wrong... Windows virtual Key code should off course be used instead of ASCII code...... Sorry.
Have corrected the above code to show the virtual key code for the "Del" key.

Title: Re: Controls and key press
Post by: Andy on April 25, 2016, 03:40:46 AM
Egil,

That works for me - thank you!

I placed

if GETKEYSTATE(0x2E) <> 0 and c = 1 in a fast timer
c = 1 is set when the edit box is clicked.

So I Need to Play around with this now.

Thanks,
Andy.



Title: Re: Controls and key press
Post by: Egil on April 25, 2016, 04:52:44 AM
That's good.  ;D

To simplify the code, you can just use:if GETKEYSTATE(0x2E)

instead of:if GETKEYSTATE(0x2E) <> 0



Title: Re: Controls and key press - Hex Editor
Post by: Andy on April 26, 2016, 07:24:39 AM
Hi,

I've managed to change the editing of registry binary values into a hex editor (thanks Egil for the suggestion - he he!)

Attached is a screenshot, and I hope by tomorrow I can release an example.

It won't take much work to use a string with hex values in rather than a registry binary value.

It shows 32 bits per page, and you can use the insert and delete buttons for inserting new entries and deleting others, also it saves any amended details correctly to the registry as a binary value that regedit can open and read.

Any suggestions / Encouragement please ?

Thanks,
Andy.
Title: Re: Controls and key press
Post by: Egil on April 26, 2016, 08:07:03 AM
Looking forward to see the finished code.
And... it was not my intention to give you extra work.  ::)

Title: Re: Controls and key press - HexEditor Download
Post by: Andy on April 27, 2016, 01:18:50 AM
Well, here is my first attempt at a hex editor.

Do not change the writting section of the program to a valid (already installed value) as you could mess up your system.

How to compile:

1. Unzip the three files
2. Copy the inc file to your IWBDev \ Include folder
3. Copy the lib file to your IWBDev \ Libs folder

(overwrite any existing copies if need be)

4. Open Regedit and go to HKEY_CURRENT_USER \ Software
5. Create a new KEY, and call it 1 (one)
6. In this new key create a reg binary entry and call it test (see attached screenshot)
7. Enter some hex values and save
8. Compile the HexEditor.iwb file

Now, you can change the values.

Using the editor:
You can use Tab to tab to the next entry, Insert to insert a space for a new value, and Delete to delete a value.

When finished, click "Save" or "Close" to abort any changes and leave the values as they where.
When you click on Save,Cancel or Close the program will end.

When you save the new values, it is stored in a new entry called "test2".

I have not added checking for valid hex values, and the size limit is 10,000 bits (but I will change that when I have time).

Please note:
If you wanted to use a string as your source for the hex values, your string would be in the form of
"A1001D62......." etc (i.e. no spaces between the hex values), however, I'm sure you could easily amend the reading in routine to accomodate spaces.

I use my StringMap Library for several reasons, I have a routine to convert any of the 256 values to Ascii plus a few other things that make it more easy to code.

Please let me know what you think.

:)
Title: Re: Controls and key press
Post by: Bill-Bo on April 27, 2016, 02:00:14 AM
Andy,

QuoteDo not change the writting section of the program to a valid (already installed value) as you could mess up your system.

Please explain in more detail. I'm not going to use a program that can mess up my system!!

Why would you write a program that could screw up your system? Why write a program that you have to create a registry entry before you can compile? I don't recall ever having to do that before. Sorry, I don't think I will do anything with this program. Viruses are bad enough, I don't need a program to mess thing up.

Bill
Title: Re: Controls and key press
Post by: Andy on April 27, 2016, 02:21:11 AM
Bill,

I think you misunderstand the warning! and none of my programs are ever made into a virus.  ???

I don't want anyone to change a registry value that already exists as they are there for a reason.

This is simply an example of how to read / edit binary values from a test registry entry, nothing else and it won't mess up your system.

It's just a warning not to change a value that already exists - that's all, this is simply a program that you can use as a hex editor if you need to work in binary.

Anyone here who knows my work will back me up on this - help me out guys.

:)

Title: Re: Controls and key press
Post by: Andy on April 27, 2016, 02:24:42 AM
And I have just noticed a small problem when moving to the next page and deleting a value (or vice versa).

So attached is the amended version to fix that issue.

:)
Title: Re: Controls and key press
Post by: Bill-Bo on April 27, 2016, 03:30:38 AM
Andy,

QuoteThis is simply an example of how to read / edit binary values from a test registry entry, nothing else and it won't mess up your system.

You seem to contradict yourself:

QuoteIt's just a warning not to change a value that already exists - that's all, this is simply a program that you can use as a hex editor if you need to work in binary.

Because if you edit something that exists, you mess things up. Why have a hex editor for the registry? Why not for files? In other words, why have a hex editor if you can't use it as a hex editor? Plus, if this is supposed to be just a demo, why not have an accompanying text file to use it on, instead of working dangerously with the registry?

Anyway, because I have to mess with my registry, I'm not going to use it.

Andy, you're a very good programmer, but I believe you need to step back and look at this again.

Bill
Title: Re: Controls and key press
Post by: Andy on April 27, 2016, 03:42:03 AM
Bill,

No contradiction at all, that's why I'm saying make a new entry yourself, one we know is not used for anything else - just for testing purposes.

I think Bill, you don't (with the greatest respect) understand what the program will do (and what it won't), and I understand you may (or may not) understand the windows registry.

I have already posted several programs such as my Registry.inc file, a registry viewer and editor, and this is my attempt at finishing off the viewer / editor.

Anyone who follows my instructions will have no problem what so ever - It's simply an exercise in editing a binary value, from a new key and value we have just made up - that's all.

And because It's one we've made ourselves, we know creating a second amended copy (under a different name) will not cause any harm as the original is left untouched.

If you're not sure about editing binary values, then I would suggest this program is not for you, which is a pitty as I believe learning something new is a good thing, given the right schooling.

If you would like to know more about the registry (what you can and what you must not do) just let me know, I would be glad to help - as I do for anyone.

Andy.

:)
Title: Re: Controls and key press
Post by: Egil on April 27, 2016, 04:26:20 AM
Andy,

I think you have made a very good job with this.
This gives me an oportunity to, in a safe way, learn more about the Windows registry file and how it is built up and used.
And at the same time it demonstrates how to use your StringMap Library.

Thank you for sharing!


Title: Re: Controls and key press
Post by: Andy on April 27, 2016, 04:36:07 AM
Egil,

Thanks for the encouragement and positive words!

My StringMap library has a lot going for it now, and there's a lot you can do with it and save a great deal of time programming.

;)
Title: Re: Controls and key press
Post by: Bill-Bo on April 27, 2016, 07:27:44 AM
Andy,

Okay. I'm going to try this out. But, will the program work on a file, other than the registry?

BTW Is this a window or console build?

Bill
Title: Re: Controls and key press
Post by: Andy on April 27, 2016, 08:20:05 AM
Bill,

This is a window program, I can post a version that will work on a file rather than the registry but it will be tomorrow as I'm busy at the moment.

And I think I will post something about the reigistry for everyone, what it is, what not to do, and how it works - I think that might help things along and take away any mystery and suspision out of it.

:)

Andy.


Title: Re: Controls and key press
Post by: Bill-Bo on April 27, 2016, 08:26:17 AM
Andy,

Okay, I did it, but it will not build. Attached are three(3) screenshots.

screenshot1 - Shows the IWBasic window with the build errors. BTW Why is line 458 commented out? It pertains to the registry entry we created before starting all this.
screenshot2 - You will find the information about the error for line 457.
screenshot3 - The screenshot after my registry entry you wanted done.

Bill

P.S. Seen you post after posting mine. That would be great, looking forward to it. And information about the registry will be great, also. Because you can sure mess things up even one wrong character.
Title: Re: Controls and key press
Post by: LarryMc on April 27, 2016, 09:16:41 AM
Bill
A bit of history
Back in 2010-2011, Andy created some functions and an editor that he shared that would read/write the registry from/to the registry.
But it would only read STRING and DWORD type entries.

What he he is doing now is working on finishing that Registry Editor by giving it the ability to to edit BINARY entries.  But he his making it easier(at Egil's suggestion I believe) by doing it in Hex.
His warnings about the Registry should be heeded.  You can destroy Windows if you aren't careful playing with the registry.
By the same token, you can go in and fix things if you know what you are doing. Hence, his editor.

And since the goal was a registry editor that is why this wasn't set up a a file hex editor
Title: Re: Controls and key press
Post by: Andy on April 27, 2016, 09:25:42 AM
Thanks Larry,

I think that explains things nicely.  ;)

I will look at amending the program to read / edit from a file for Bill tomorrow as I'm a bit pushed for time right now.

Thanks again,

Andy.
:)
Title: Re: Controls and key press
Post by: Bill-Bo on April 27, 2016, 09:42:33 AM
LarryMc,

Well, the hex editor part through me off, and thanks for the history. All hex editors I've used worked on files. Maybe it should be call "Hex Registry Editor," or "Registry Hex Editor," or "Registry Changing Program That Uses Hex, And If You Don't Watch Out You Can Mess Up Your Computer Editor." Pardon me, I was just being silly.

Andy,

Like I mentioned earlier, looking forward to it.

To both,

No comment on my not being able to build!!

Bill
Title: Re: Controls and key press
Post by: Andy on April 27, 2016, 09:59:24 AM
Bill,

You have to copy the StringMap.inc file to your C:\Program Files\IWBDev\Include folder, and the StringMap.lib file to C:\Program Files\IWBDev\libs folder (if it asks you to overwrite existing files click copy and replace / yes).

It will compile then.


Andy.
Title: Re: Controls and key press
Post by: Bill-Bo on April 27, 2016, 01:02:00 PM
Andy,

I had done that before I even loaded the program. Now, I have my IWBasic installed in my dir "My Programs." I renamed the dir and did a normal install in the "Program Files (x86)" dir. Installed the inc and lib, and loaded the program. This time it wouldn't build because it couldn't open the file the program creates.

I deleted the install and did one to my C root dir. This time it built and ran. Weird.

Bill
Title: Re: Controls and key press
Post by: Andy on April 27, 2016, 11:51:28 PM

Attached is the hex editor for a file, this one works from a string:

e.g. "A1 00 12 BF 04....." etc

Click "Save" to close the window and see the console output.

Bill,

Yes your compile problem is very strange.....

Andy.
Title: Re: Controls and key press
Post by: Bill-Bo on April 28, 2016, 01:21:25 AM
Andy,

I'm sorry, but I do not see how your hex editor can be of any use. It seems useless to have to enter a hex string into a program and run it to edit it, when you can do the editing right then and there. Most any hex editor you find on the internet, you open a file and the hex is displayed on the left and the ASCII on the right. And you can do the editing on either side. Yours does not open a file to edit. It displays a string from within the program to edit. You can edit only on the hex side. And, any edits you make cannot be saved, even though, it you have a save button.

It neat what you did, but you have to enter a string into the program itself, you can't open and external file and edit it. Or, even save it.

Bill
Title: Re: Controls and key press
Post by: Andy on April 28, 2016, 02:03:37 AM
Bill,

This new example was just to show you how you can load hex values into the Editor, page through and make amendments.

This example can easily be changed to read in a file instead of a string, and then save the changes to a file.

QuoteYou can edit only on the hex side
Rome wasn't built in a day.

QuoteI'm sorry, but I do not see how your hex editor can be of any use. It seems useless to have to enter a hex string into a program and run it to edit it, when you can do the editing right then and there.

It's not about the source of the hex values, or where you are saving them - It's about a working Editor for hex values.

Andy.


Title: Re: Controls and key press
Post by: Bill-Bo on April 28, 2016, 08:24:57 AM
Andy,

Okay. Please don't get mad. I'd play hell doing the coding you do. Plus, I'm grateful for all the help you've provided me the last couple months or more.

Keep up the great work.

Bill

Title: Re: Controls and key press
Post by: Andy on April 28, 2016, 08:33:59 AM
Bill,

Don't worry, not getting mad at all.  :)
And thanks for the compliment!

Andy.
Title: Re: Controls and key press - Registry viewer / editor almost there
Post by: Andy on April 29, 2016, 08:22:27 AM

For those of you who might be interested, I've now added in Adding / Editing binary and Expandable strings into my registry viewer / editor.

I now have the last task - learn how to read / edit multi strings, after that I will be very happy with the program and will upload a copy.

See attached screenshot.

Thanks,
Andy.