|
I believe you will have to look into the HookProc. The MSDN docs in CommonDialog.HookProc says the center the window on the WM_INITDIALOG.
Rocky Moore <><
|
|
|
|
|
Do you know of any good examples of how to use hookproc? I got that far, but I did not want to waist an hour figuring it out.
Thanks,
Jerry
|
|
|
|
|
This should do you:
public class myColorDlg : ColorDialog
{
[DllImport("User32", SetLastError=true)]
public static extern bool SetWindowPos(IntPtr hWnd,IntPtr hWndInsertAfter,int X,int Y,int cx,int cy,int uFlags);
protected override System.IntPtr HookProc(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam)
{
System.IntPtr returnValue = base.HookProc(hWnd,msg,wparam,lparam);
if(msg == 0x0110)
{
SetWindowPos(hWnd,(IntPtr)0,50,50,0,0,
0x0001 |
0x0004 |
0x0010);
}
return returnValue;
}
}
Rocky Moore <><
|
|
|
|
|
Thanks for your help! It worked great. One more question (I am new to .NET ) Where are the windows messages defined?
I found
const int WM_SETFOCUS = 0x0007;<br />
const int WM_INITDIALOG = 0x0110;<br />
const int WM_LBUTTONDOWN = 0x0201;<br />
const int WM_RBUTTONDOWN = 0x0204;<br />
const int WM_MOVE = 0x0003;
on MSDN, but is there a complete list somewhere?
Thanks again,
Jerry
|
|
|
|
|
Hey all,
I'm trying to create a new EnhancedImage class derived from a System.Drawing Image class, but I keep getting the error "System.Drawing.Image.Image()' is inaccessible due to its protection level". Is it possible that you just can't derive from this class? I posted my code for the class below. It's pretty simple so far, just a constructor. Any thoughts would be appreciated. Thanks.
using System;
using System.Drawing;
namespace WindowsApplication1
{
public class EnhancedImage : Image
{
public EnhancedImage(string imageFilename)
{
FromFile(imageFilename);
}
}
}
-Mike Zinni
"No sh*t it's tough. If it wasn't, everybody and their sister would be an engineer and then you wouldn't have a job."
|
|
|
|
|
I have no idea if this would work, but possibly the Image abstract class has its default constructor as private and that is what you are calling, so it may require that you use one of its defined constructors, and I noticed the Bitmap class does not use a default contructor either. I think this would work... if it doesn't, then i have no idea.
notice this line:
public EnhancedImage(string imageFilename) : base( imageFileName )
<br />
using System;<br />
using System.Drawing;<br />
<br />
namespace WindowsApplication1<br />
{<br />
public class EnhancedImage : Image<br />
{<br />
public EnhancedImage(string imageFilename) : base( imageFileName )<br />
{<br />
FromFile(imageFilename);<br />
}<br />
}<br />
}<br />
|
|
|
|
|
I have an unusual situation, which I am unsure of how to tackle. I have an old c api that I need to access in a c#.net web application. My initial thoughts are to build a c dll with functions that I can call from c# using ATL or COM. But that is a big (and intimidating) leap on how to accomplish it. Does anyone have suggestions on a better architecture or how I can get there? Simple examples would be a big plus. Thanks.
Courtney
|
|
|
|
|
Its either what you suggested or build a wrapper around your C code using MC++. I dont think there are other options.
|
|
|
|
|
You have three choices from what I can tell:
1. Wrap it in com and do the calling from C#
2. Wrap it with Managed C++
3. Use DllImport to do it directly in C#
Choice #3 would be my first choice. Check out the System.Runtime.Interopservices namespaces. How complicated of a C api? Are you passing structs and unions and tons of pointers? Or just ints and doubles?
-Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
Option 3 sounds the simplest, I was unsure if that was possible.
My c api is not very complicated, just not very portable. The api relies on a properly setup application environment to function correctly. Mostly environment variables and an oracle client.
Here is a dll I created to perform a simple query. I can easily call this from another c/cpp console app and everything works fine. Jut not sure how to get it into a c#.net app.
Code Example:
#include <prointlnk.h>
#include <string.h>
#include <stdlib.h>
__declspec(dllexport) char* query(char*);
char* query(char* instring)
{
static char outstring[256];
char buff[20];
HPDMPDM pdm;
PTCERROR err = PDM_SUCCESS;
HPDMPI pi_handle = NULL_HPDMPI;
HPDMBRANCH branch_handle = NULL_HPDMBRANCH;
HPDMPIV piv_handle = NULL_HPDMPIV;
PTCSTRING piv_rev = NULL, part_name = NULL;
PTCINTEGER piv_ver = 0;
err = PDMConnectToPDM("username", "password", &pdm);
err = PDMPIGetByName( instring, &pi_handle );
if ( PDM_HANDLE_IS_NULL( pi_handle ))
{
strcpy( outstring, "Object Not Found" );
return outstring;
}
// Get the main branch handle.
err = PDMPIGetMainBranch( pi_handle, &branch_handle );
// Get the latest PIV handle.
err = PDMBranchGetLatestPIV( branch_handle, &piv_handle );
// Get the revision and version.
err = PDMPIVGetRevision( piv_handle, &piv_rev );
err = PDMPIVGetVersion( piv_handle, &piv_ver );
// Construct the output string. Longterm goal is XML string
strcpy( outstring, "name = '" );
strcat( outstring, instring );
strcat( outstring, "';" );
strcat( outstring, "rev = '" );
strcat( outstring, piv_rev );
strcat( outstring, "';" );
_itoa (piv_ver,buff,20);
strcat( outstring, "ver = '" );
strcat( outstring, buff );
strcat( outstring, "'" );
return outstring;
}
|
|
|
|
|
I believe you would just declare the function as:
[System.Runtime.Interopservices.DllImport("MyDll.dll")]<br />
private extern static string query(string instring);
That is a simple example. You might need to look at the strings a little bit more (ie use a StringBuilder or something instead). I am not a guru of interop. But this should get you started.
-Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
My company wants to extend the XML comments feature of C# with some extra tags.
I was wondering if anyone knows how to add extra tags to intellisense, so that they appear alongside the likes of , <example> etc.. within the comment are above a member / class.
Thanks in advance
Donald
|
|
|
|
|
Hi !
I have an owner draw panel in my forms application. It works well but it's not perfect with standard control (like labels, or checkbox) with transparency background activated. Transparency works fine but controls is a bit slower to be displayed. Is there a way to double bufferize controls drawing inside the panel ? (am i clear ? )
Anyone has any suggestion ?
Thanks for help.
--
F.Julian
|
|
|
|
|
Is there anyway to find out all the available drives to the PC on which a program is running? If so how?
|
|
|
|
|
System.IO.Directory.GetLogicalDrives
Rocky Moore <><
|
|
|
|
|
I have one crystal report, where I show all tables T fields. What I need is that those fields should look like a table with borders, like normal Excels table with black borders.
First problem is that, I need to move those fields together by hand (or does crystal rep. have features something like access has?)
And the biggest porblem that I do not know is: how to make fields with no data show? I made a single borders for all fields, but if the current field is empty, the crystal report suppreses it (no borders are shown)???
Does anyone knows how to make those borders be veasible all the time?
Thanx
|
|
|
|
|
Hi,
I'm trying to copy data from File to File,
and having some problem...
I've just created the two File, using:
File.create(file1);
File.create(file2);
and now trying to copy from one to another, using:
File.copy(file1, file2, true);
File.delete(file1);
I can compile it, but on ruuning time- it falls in the "copy" command, with the excaption the file2 is in use.
what should I do???
|
|
|
|
|
Make sure you close the files before attempting to copy.
Cheers,
Kannan
|
|
|
|
|
:-OThank you for your response, but...
I don't know any command in C#/File
(such as File.close)
that closes the file.
how do I do that???
Thanks again,
Iris
|
|
|
|
|
:-OThank you for your response, Kannan, BUT...
I'm not femiliar with any command to close the file, such as File.close...
Can you please let me know how to do that???
Thanks again,
Iris.
|
|
|
|
|
I'm sorry, I just assumed there would be a Close method you can call.
Seems like Close method is present only for stream derived classes.
Do you write to the file using the Stream class, if so try to close them before you copy.
Also try using FileInfo's CopyTo method (I doubt it would help, but just give it a try).
Kannan
|
|
|
|
|
Hi,I'm trying to rename a lot of files,how to implement this function.
|
|
|
|
|
I think you might be looking for System.IO.File.Move() or System.IO.FileInfo.MoveTo(). That moves the file which is the same as renaming. You move it to the same directory but under a different name.
Rocky Moore <><
|
|
|
|
|
|
Hi Friends!! If I draw a black color vector Graphic in a white DC, how can I know any pixel in DC is black or white ? thx !
|
|
|
|