May 15, 2024, 01:36:47 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Controls and key press

Started by Andy, April 24, 2016, 11:35:16 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy


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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

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


LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

or do  you mean the Del key?
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy


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

Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Egil

April 25, 2016, 02:42:04 AM #4 Last Edit: April 25, 2016, 03:19:13 AM by Egil
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.

Support Amateur Radio  -  Have a ham  for dinner!

Andy

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.



Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Egil

That's good.  ;D

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

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



Support Amateur Radio  -  Have a ham  for dinner!

Andy

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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Egil

Looking forward to see the finished code.
And... it was not my intention to give you extra work.  ::)

Support Amateur Radio  -  Have a ham  for dinner!

Andy

April 27, 2016, 01:18:50 AM #9 Last Edit: April 27, 2016, 01:49:56 AM by Andy
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.

:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Bill-Bo

April 27, 2016, 02:00:14 AM #10 Last Edit: April 27, 2016, 02:06:07 AM by Bill-Bo
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

Andy

April 27, 2016, 02:21:11 AM #11 Last Edit: April 27, 2016, 02:42:26 AM by Andy
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.

:)

Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

April 27, 2016, 02:24:42 AM #12 Last Edit: April 27, 2016, 02:27:15 AM by Andy
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.

:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Bill-Bo

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

Andy

April 27, 2016, 03:42:03 AM #14 Last Edit: April 27, 2016, 04:04:49 AM by Andy
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.

:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Egil

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!


Support Amateur Radio  -  Have a ham  for dinner!

Andy

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.

;)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Bill-Bo

April 27, 2016, 07:27:44 AM #17 Last Edit: April 27, 2016, 07:30:25 AM by Bill-Bo
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

Andy

April 27, 2016, 08:20:05 AM #18 Last Edit: April 27, 2016, 08:21:44 AM by Andy
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.


Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Bill-Bo

April 27, 2016, 08:26:17 AM #19 Last Edit: April 27, 2016, 08:31:01 AM by Bill-Bo
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.

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

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.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Bill-Bo

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

Andy

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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Bill-Bo

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