Quantcast
Viewing all articles
Browse latest Browse all 3527

WinAPI CreateWindowEx gives error in C# .net framework 4.5

Hi..

I have window based project in C#  and it is created in VS2005 targeted framework 2.0,now i am upgraded it to VS2012 targeted framework 4.5. In my project i had some PInvoke functions of ole32.dll, user32.dll, etc.

But after upgradation my user32.dll "CreateWindowEx" API fails and its causing error and i am not able to catch it in catch block to know what exception is it. But the all same code  in VS2005 works fine. Below are the code snippet of my API.

ScreenForm.Show(); //call to the form that i try to show

_m_Ctrl = new W5.EditLD();//my wrraper classes
                        bCreate = _m_Ctrl.CreateWnd(WinAPI.CWnd.WS_VISIBLE | WinAPI.CWnd.WS_BORDER |                                 WinAPI.CWnd.WS_CHILD,
                                                                          0, 0, 100, 100,
                                                                          Handle, //handle of my windows form 

                                                                      IDC_MAIN);/my wrraper method

                          [DllImport("user32.dll")]
                           public static extern IntPtr CreateWindowEx( uint dwExStyle, string lpClassName, string lpWindowName,
                                                    uint dwStyle,
                                                    int x, int y, int width, int height,
                                                    IntPtr hWndParent,
                                                    IntPtr hMenu, IntPtr hInstance, IntPtr lpParam); //my DLL import definition

In above call only my c# windows form handle is variable, and all other attribute is constant.

Please help me to figure out it.

Thanks & Regards,

Suraj


Viewing all articles
Browse latest Browse all 3527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>