Sandip's Programming Zen

An attempt to share tech/coding experiences

Archive for January 2011

Running 32 bit applications on 64 bit OS

with one comment

Lately I ran into a problem where I created a feature where user can view PDF within a winform application. To do that I first used a web browser control since it was a simple solution where you just need to provide pdf path to the navigate property. That works without problem on Win XP (32bit) , but as soon as user runs it on his Vista (64 bit) OS  , it behaved different , that said, pdf opens but in a separate window, which looks bit odd, so must be fixed.

To solve that problem , I have removed web browser control and placed Acrobat Reader control (assuming that all of my users will have at least Adobe reader installed). Now that again worked well on Win XP but simply crashed on Vista (64 bit).  Reason was Acrobat reader control is an ActiveX control which is 32 bit component , that won’t work on a 64 bit OS. After looking around for some time and find out there is no 64 bit version of Acrobat reader, I discovered that I have to make sure that my win form app runs under 32 bit process on a 64 bit OS. To, do that you have to change Target Platform property of your project (See screenshot below).

Bottom line is if you have any project dependencies which only works on 32 bit environment, you have to change your project’s target platform to run only under 32 bit process. That will make your app work fine on both 32 bit and 64 bit OSes.

target_platform

Written by Sandip

January 9, 2011 at 10:44 pm

Posted in .Net, Programming, Windows

Tagged with , , ,

Solution: Problem of focus when opening a Winform using Treeview node click

leave a comment »

I must blog this , since I could not find the fix as quickly as I should. So…
When you try to open a winform using treeview node selection (using any event like mouse_click on after_select) , the form opens, but it remains minimized even if you have set the focus and windowstate properties.  That is because treeview regains control after opening form, however there is no direct fix.  You can fix it by delaying the action of the event.

        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            this.BeginInvoke(new TreeViewEventHandler(delayedClick), sender, e);
        }

        private void delayedClick(object sender, TreeViewEventArgs e)
        {
             // your code goes here…
        }

Original solution here.

Written by Sandip

January 6, 2011 at 4:12 pm

Posted in .Net

Tagged with