Author Topic: Replace existing Form with another one  (Read 4720 times)

0 Members and 1 Guest are viewing this topic.

LE3

  • Guest
Replace existing Form with another one
« on: November 27, 2010, 06:35:36 PM »
Hi,
I did a .NET project using a commercial spreadsheet control (excel alike), but it is not provided with the possibility of Localization, it is all just in English, (have contacted the developers, and so there are no plans to do this), anyway have done it the replacement of all the text from all the controls parent and child's to Spanish (the first Localization language translation, see attached images samples Spanish from the existing English one).

Now my question is, if anyone have done such task? of replacing existing forms with a better new forms and continue having the same behavior... or could be a high risk of doing this hack?

Easy?, way To difficult, Over looking? :)

Note: all the update it is done in runtime using EnumWindowsProc & EnumChildWindows callbacks.
Thanks.
« Last Edit: November 27, 2010, 08:03:11 PM by LE »

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Replace existing Form with another one
« Reply #1 on: November 27, 2010, 11:52:08 PM »
Interesting .. I never did this before

Did you think about simply opening the executable in reshacker and simply updating the resources. If the form is pre-built you can simply change the information in the control to make it language specific. If it is built dynamically, you can edit the string table. In the end, you should be able to do it without having to execute a bunch of API calls.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

LE3

  • Guest
Re: Replace existing Form with another one
« Reply #2 on: November 28, 2010, 12:18:37 AM »
Interesting .. I never did this before

Did you think about simply opening the executable in reshacker and simply updating the resources. If the form is pre-built you can simply change the information in the control to make it language specific. If it is built dynamically, you can edit the string table. In the end, you should be able to do it without having to execute a bunch of API calls.

I did an small winapi class with a bunch of pinvoke calls, it is not doing to many calls at all - just one at the time when an item it is clicked on a ContextMenuStrip.

Reshacker does not work for this control.
Have tried also the route of reflection and nope....

I have been able so far to replace the form with a new one (have a look at the first try-out output), the problem I have now it is the location of the controls... 

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Replace existing Form with another one
« Reply #3 on: November 28, 2010, 12:35:42 AM »
Is this a file you could share with me so I can take a look at it?
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

LE3

  • Guest
Re: Replace existing Form with another one
« Reply #4 on: November 30, 2010, 10:14:35 PM »
Some update ( and will try to write something about how to do this, when I get a chance or as time permits, that might helps others here ):

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Replace existing Form with another one
« Reply #5 on: November 30, 2010, 10:31:11 PM »
Interesting Luis, Did you actually recreate the windows (and if so, how did you recreae the functionality) or did you simply update the control with SetWindowText?

As a side note, it appears as though the combo boxes are loaded with strings that are not localized. Is that something you are working on or is it ok like it is?
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

LE3

  • Guest
Re: Replace existing Form with another one
« Reply #6 on: November 30, 2010, 10:48:29 PM »
Interesting Luis, Did you actually recreate the windows (and if so, how did you recreae the functionality) or did you simply update the control with SetWindowText?

As a side note, it appears as though the combo boxes are loaded with strings that are not localized. Is that something you are working on or is it ok like it is?

I moved the existing controls into the new Form and kept the same events, and added some new functionality - sizable, titlebar icon, etc.

Some parts like the comboboxes values, will be left as-is - to keep any internal functionality, that I do not want to break - for example in the case that inside they are comparing string==string values, etc.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Replace existing Form with another one
« Reply #7 on: December 01, 2010, 03:00:12 AM »
So you just created a blank form, changed the parent of the enumerated controls and continued to operate in that fashion? Interesting I would be concerned that the core programming had localized references that would break if the parent of the control changed.

I am awaiting the tutorial on how to accomplish this. It sounds positively intriguing.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

LE3

  • Guest
Re: Replace existing Form with another one
« Reply #8 on: December 01, 2010, 09:37:25 PM »
So you just created a blank form, changed the parent of the enumerated controls and continued to operate in that fashion? Interesting I would be concerned that the core programming had localized references that would break if the parent of the control changed.

I am awaiting the tutorial on how to accomplish this. It sounds positively intriguing.

Went into reflection and found that they use enumerations for all their comboboxes values, so I will be safe to also localize those values, without any issue :)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Replace existing Form with another one
« Reply #9 on: December 01, 2010, 09:55:50 PM »
Quite a feat Luis, I would be interested to see a working schema on how this might be applied to other applications and/or controls that are not localizable.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie