473,395 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

VB to C# - Small Code Conversion HELP

Anyone who could convert the following VB Code to C#? i've tried using auto converters, but it always yeilds errors.. and i have no background in VB whatsoever... thanks!

i can't seem to figure out lines 6 to 8, and 16 to 17..

Expand|Select|Wrap|Line Numbers
  1. Private Const HWND_TOPMOST = -1
  2. Private Const HWND_NOTOPMOST = -2
  3. Private Const SWP_NOACTIVATE = &H10
  4. Private Const SWP_SHOWWINDOW = &H40
  5.  
  6. Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
  7. ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, _
  8. ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
  9.  
  10. Code:
  11. Private Sub SetWindowOnTop(f As Form, bAlwaysOnTop As Boolean)
  12.    Dim iFlag As Long
  13.  
  14.    iFlag = IIf(bAlwaysOnTop, HWND_TOPMOST, HWND_NOTOPMOST)
  15.  
  16.    SetWindowPos f.hwnd, iFlag, f.Left / Screen.TwipsPerPixelX, f.Top / Screen.TwipsPerPixelY, _
  17.                 f.Width / Screen.TwipsPerPixelX, f.Height / Screen.TwipsPerPixelY, SWP_NOACTIVATE Or SWP_SHOWWINDOW
  18. End Sub
  19.  
Sep 7 '07 #1
3 2874
vanc
211 Expert 100+
const int HWND_TOPMOST = -1;
const int HWND_NOTOPMOST = -2;
const string SWP_NOACTIVATE = "&H10";
const string SWP_SHOWWINDOW = "&H40";


private long SetWindowPos(long hwnd,long hWndInsertAfter, long x,long y ,long cx,long cy,long wFlags)
{
return 0;
}

private void SetWindowOnTop(Form f, bool bAlwaysOnTop)
{
long iFlag;

iFlag = 0;//(bAlwaysOnTop, HWND_TOPMOST, HWND_NOTOPMOST)
//I have no idea about the above line of code !!! :D
SetWindowPos(f.hwnd, iFlag, f.Left / Screen.TwipsPerPixelX, f.Top / Screen.TwipsPerPixelY, f.Width / Screen.TwipsPerPixelX, f.Height / Screen.TwipsPerPixelY, SWP_NOACTIVATE, SWP_SHOWWINDOW);
Sep 7 '07 #2
RoninZA
78
iFlag = 0;//(bAlwaysOnTop, HWND_TOPMOST, HWND_NOTOPMOST)

translatres to:

Expand|Select|Wrap|Line Numbers
  1. iFlag = bAlwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST;
  2.  
Sep 7 '07 #3
Plater
7,872 Expert 4TB
My question is why are trying to do native API calls in .NET.
All the windows come with these kind of functions already wrapped nicely for you
Sep 7 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Dr. Mercury | last post by:
Greetings to all - Someone suggested that Java might be the answer for a little conversion program I need. It's pretty simple, really. Just take a column of numbers: 139 259 433 637
2
by: sal cifone | last post by:
Hello, I am trying to use access vba instead of running an unmatched query. I want to compare two tables and if there is a new sales office in "Commissions" table that is not in the "Conversion"...
7
by: astro | last post by:
Anyone have suggestions on where to troubleshoot this error? Background: -Access 2k v. 9.0.6926 sp3 - front and backend on production server (wiindows 2k) -accessed via Citrix -front-end is...
4
by: Macin | last post by:
Hi, How to efficently divide big array into small arrays as showed below? IN xxxxxxxxxxxxxx xxxxx xxxxx xxxxx xxxxxxxxxxxxxx xxxxx xxxxx xxxxx...
3
by: nan | last post by:
Hi All, I am trying to connect the Database which is installed in AS400 using DB2 Client Version 8 in Windows box. First i created the Catalog, then when i selected the connection type...
0
by: NM | last post by:
Hello, I've got a problem inserting binary objects into the postgres database. I have binary objects (e.g. images or smth else) of any size which I want to insert into the database. Funny is it...
169
by: JohnQ | last post by:
(The "C++ Grammer" thread in comp.lang.c++.moderated prompted this post). It would be more than a little bit nice if C++ was much "cleaner" (less complex) so that it wasn't a major world wide...
1
JavaStudent07
by: JavaStudent07 | last post by:
I have a list, I need to print it out in characters as a "Secret Message" :) this is the list, have any ideas on the conversion methods from the numbers to ASCII code format for me? 67 79 77 80 85...
25
by: mereba | last post by:
Hello My country Ghana is changing its currency. I want to write a small programme in C++ that can covert from the old currency into the new one. I would like this programme to run behind a simple...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.