Click here to Skip to main content
15,906,816 members
Home / Discussions / C#
   

C#

 
GeneralConverting an Image to an Icon Pin
Adam Turner10-Nov-03 13:47
Adam Turner10-Nov-03 13:47 
GeneralRe: Converting an Image to an Icon Pin
Corinna John10-Nov-03 19:54
Corinna John10-Nov-03 19:54 
GeneralNew Line in CF textbox Pin
gadgetfbi10-Nov-03 13:01
gadgetfbi10-Nov-03 13:01 
GeneralRe: New Line in CF textbox Pin
MultiThread10-Nov-03 16:54
MultiThread10-Nov-03 16:54 
QuestionHow to retrieve the initial window state? Pin
Alvaro Mendez10-Nov-03 12:20
Alvaro Mendez10-Nov-03 12:20 
AnswerRe: How to retrieve the initial window state? Pin
Heath Stewart11-Nov-03 3:38
protectorHeath Stewart11-Nov-03 3:38 
GeneralRe: How to retrieve the initial window state? Pin
Alvaro Mendez11-Nov-03 4:33
Alvaro Mendez11-Nov-03 4:33 
GeneralRe: How to retrieve the initial window state? Pin
Heath Stewart11-Nov-03 6:54
protectorHeath Stewart11-Nov-03 6:54 
The runtime doesn't expose near as much as what Win32 would. Otherwise ListViews would support grouping, working areas, multiple column sorting, and filter columns. It doesn't. Forms would support drop-shadows. They don't. In these and many other cases, you have to P/Invoke code and often defines structs and enums/consts. These are wrapper classes - and early ones at that.

If you need the window state before the application window (main form) is shown in a purely .NET manner, you're sunk.

You could P/Invoke GetWindowPlacement and redefine the WINDOWPLACEMENT struct in the Windows Manager functions (see MSDN Library for this function for more information). It requires an HWND, which you can easily get from Form.Handle (inherited from Control). Something like this:
// Somewhere in your form or other class, define...
[DllImport("user32.dll")]
private static extern bool GetWindowPlacement(IntPtr hWnd, ref WindowPlacement placement);
// Later as a nested struct or internal struct...
internal struct WindowPlacement
{
  public int length;
  public int flags;
  public int showCmd;
  public POINT ptMinPosition;
  public POINT ptMaxPosition;
  public RECT rcNormalPosition;
}
internal POINT
{
  public long x;
  public long y;
}
internal RECT
{
  public long left;
  public long top;
  public long right;
  public long buttom;
}
// When you call the function...
WindowPlacement placement = new WindowPlacement();
placement.cbSize = Marshal.SizeOf(placement);
if (GetWindowPlacement(this.Handle, ref placement))
{
  int nCmdShow = placement.showCmd;
  // See the SW_* #defines in WinUser.h for values.
}


 

-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
GeneralRe: How to retrieve the initial window state? Pin
Alvaro Mendez11-Nov-03 8:48
Alvaro Mendez11-Nov-03 8:48 
GeneralRe: How to retrieve the initial window state? Pin
Heath Stewart11-Nov-03 8:53
protectorHeath Stewart11-Nov-03 8:53 
GeneralComputer name Pin
Chathura10-Nov-03 12:10
Chathura10-Nov-03 12:10 
GeneralRe: Computer name Pin
Heath Stewart11-Nov-03 3:43
protectorHeath Stewart11-Nov-03 3:43 
GeneralActive Directory Adding Pin
Chathura10-Nov-03 11:53
Chathura10-Nov-03 11:53 
Questiona way to use arrays with negative pointers? Pin
Demokritos10-Nov-03 11:26
Demokritos10-Nov-03 11:26 
AnswerRe: a way to use arrays with negative pointers? Pin
Wjousts10-Nov-03 11:39
Wjousts10-Nov-03 11:39 
GeneralRe: a way to use arrays with negative pointers? Pin
Demokritos11-Nov-03 12:40
Demokritos11-Nov-03 12:40 
GeneralConvert string to class (sort of) Pin
MrEyes10-Nov-03 6:30
MrEyes10-Nov-03 6:30 
GeneralRe: Convert string to class (sort of) Pin
Wjousts10-Nov-03 7:06
Wjousts10-Nov-03 7:06 
GeneralRe: Convert string to class (sort of) Pin
MrEyes10-Nov-03 7:09
MrEyes10-Nov-03 7:09 
GeneralRe: Convert string to class (sort of) Pin
Heath Stewart10-Nov-03 7:44
protectorHeath Stewart10-Nov-03 7:44 
GeneralA couple of line drawing questions... Pin
DoofToo10-Nov-03 6:12
DoofToo10-Nov-03 6:12 
GeneralRe: A couple of line drawing questions... Pin
mhmoud rawas11-Nov-03 1:36
mhmoud rawas11-Nov-03 1:36 
GeneralPrinting.. Pin
Amirjalaly10-Nov-03 5:50
Amirjalaly10-Nov-03 5:50 
GeneralRe: Printing.. Pin
Heath Stewart10-Nov-03 6:01
protectorHeath Stewart10-Nov-03 6:01 
GeneralRemoting and Events Pin
CillyMe10-Nov-03 5:08
CillyMe10-Nov-03 5:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.