|
A few tips, first: don't use <code> within a <pre> tag. The former is for in-line code, and the latter is for block code.
Also, don't handle events for the control class you're extending. It is much faster and you have more control by overriding OnHandleCreated , or any of the OnEventName handlers defined by the base class. This lets you call base.OnHandleCreated if you want (in this case you should, but there are times you might not want to when overriding WndProc , for example). It's also much faster code. To invoke a delegate, many, many IL instructions are required. To call a virtual function it's one: callvirt .
The Rich Edit control doesn't expose its scroll bars in the same way as other controls. If you look at the message documentation for the Rich Edit control like I mentioned before you might notice an EM_SHOWSCROLLBAR message you can send by P/Invoking SendMessage like so:
[DllImport("user32.dll")]
private static extern int SendMessage(IntPtr hWnd, int msg, ScrollBar sb, bool show);
private enum ScrollBar
{
Horizontal,
Vertical
} Please note that this signature is not 64-bit compatible, however. In such a case, both return value and the last two params should be IntPtr s, which is a system-dependent bit width.
Then, just send EM_SHOWSCROLLBAR (0x0460) with the params you require.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Dear Heath,
Thanks for the tips. I will keep in mind for future postings.
I tried sending EM_SHOWSCROLLBAR message by P/Invoking SendMessage , But It did not work in my case.
However, I could solve the problem by P/Invoking GetSystemMetrics , CreateRectRgn , SetWindowRgn .
I am pasting the code for future reference.
private const int SM_CXVSCROLL = 2;
[System.Runtime.InteropServices.DllImport("user32")]
public static extern int GetSystemMetrics(int nIndex);
[System.Runtime.InteropServices.DllImport("gdi32")]
public static extern int CreateRectRgn(int X1, int Y1, int X2, int Y2) ;
[System.Runtime.InteropServices.DllImport("user32")]
public static extern int SetWindowRgn(int hwnd, int hRgn, bool bRedraw);
public void HideVerticalScrollBar(RichTextBox rtb)
{
int scrollbarWidth = WinApi.GetSystemMetrics(SM_CXVSCROLL);
int handleRgn = WinApi.CreateRectRgn(0, 0, rtb.Width , rtb.Height);
rtb.Width += scrollbarWidth;
WinApi.SetWindowRgn(rtb.Handle.ToInt32(), handleRgn, true);
}
Regards,
Jay.
|
|
|
|
|
Hi,
I'm writing a program which manages a XML file. Here is the problem:
1)this code works ->
<?xml version="1.0"?>
<manifest identifier="manifest-5972687/packet0">
<metadata />
doc.SelectSingleNode("/manifest"); - where doc is a XmlDocument.
2)but this code doesn't ->
<?xml version="1.0"?>
<manifest xmlns="http://www.imsglobal.org/xsd/imscp_v1p1" xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" identifier="MANIFEST-3F664D24-D315-486E-61AE-97BCA62EF017" xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1 imscp_v1p1.xsd http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">
doc.SelectSingleNode("/manifest");
so when I try to apply the above attributes to the "manifest", I get exceptions everywhere I use the SelectSingleNode function in my code(also all XPath expressions fail to work!!).It's possible to use doc.DocumentElement; property but in this case I have to change a lot of code and this doesn't seem to me logical . Can you help me? Thanks in advance.
Best Regards
Velin
|
|
|
|
|
Create an instance of a XmlNamespaceManager , and apply those extra namespaces, then pass the instance to SelectSingleNode()
top secret xacc-ide 0.0.1
|
|
|
|
|
Thanks Leppie. I'll try it!
|
|
|
|
|
Can i create image frames from metafiles.
My program works for creating image frames from any types of images, but not from metafiles.
Can i know how to create image frames from metafile images and also for a combination of metafile images and others like gif,jpeg..?
|
|
|
|
|
I am having 2 unrelated problems and was hoping one of you would be able to help me.
Firstly i have just downloaded the directX SDK, I know how to include the libraries in VS6 but i'm now using 2003 and i don't know what to do to get the IDE to recognise
using System.Microsoft.DirectX;
Secondly, i am trying to use the DllImport attribute but am getting a message saying the type or namespace "DllImport" could not be found. The line of code is
[DllImport("user32.dll")]
Followed by a function definition
Any help that you guys can give me to solve these problems would be greatly appreciated.
|
|
|
|
|
I have figured out the DllImport problem, i wasn't including the
System.Runtime.InteropServices;
Still having the directX problem though.
|
|
|
|
|
1.
It sounds like you missed to add a reference for the library. The using directive only permits the use of types in a namespace, such that, you do not have to qualify the use of a type in that namespace.
To reference the library, go to the solution explorer, right-click on References and select "Add reference".
2.
You'll have to import the types of System.Runtime.InteropServices namespace to use the DllImportAttribute Class the way your doing.
using System.Runtime.InteropServices;
[DllImport("user32.dll")]
Followed by a function definition
|
|
|
|
|
OK, sorted the DllImport problem, thanks.
Back to directX. What you are saying is true, i am missing the reference to the assembly but, DirectX is huge, you wouldn't add a reference to each DLL manually.
In Visual Studio 6, you added a reference to the relevant library folder and include folder, then you could just use the functions as though they were system functions. In 2003, if you include the relevant libraries then you can either use the fully qualified namesapce
Microsoft.DirectX.DirectDraw etc
or have a using statement as you would with any other system library.
Anyone that knows what i am doing wrong, i have installed directX SDK 9, or knows of a good tutorial for getting up and running with managed DirectX, your help would be appreciated.
|
|
|
|
|
There are some articles[^] available here on CodeProject.
Also there is a preliminary documentation on MSDN[^]
|
|
|
|
|
Hi all,
has anybody ever tried to edit a bitmap programatically?
I have a bitmap of a printed circuit board, but around the board are white margins.
I would like to remove the white margins in my program.
Is this possible?
Best Regards
Bernd
-------------------------------------------
The light at the end of the tunnel has been switched off temporarily due to budget problems...
|
|
|
|
|
Of course it is. Programs like Photoshop do this all the time. The real question is how your going to detect the edge between the image and the white space you want to get rid of and what you want to do about it. DO you replace it with the green PCB or do you crop the image. There are all kinds of algorithms around for edge detection, but what will work for you is up t your own testing and research.
Edge Detection Algorithm[^] searh results on Yahoo.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks!
I'll have a look at this.
-------------------------------------------
The light at the end of the tunnel has been switched off temporarily due to budget problems...
|
|
|
|
|
I am not familiar with Discussion Forum.
|
|
|
|
|
What's not to understand? You go there, you post questions, you read responses and replies... You obviously got part of it right, you posted something here.
I take it you had a more specific question about some discussion forum software?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How to get the list of installed fonts corresponding to any perticular charactor set? eg. if I want to get Japanese supporting font list (corresponding to char set Shift_JIS), how to do it?
please guide
|
|
|
|
|
You can get a list of the installed fonts by instantiating System.Drawing.Text.InstalledFontCollection . Enumerate through the FontFamilies array property. This information won't tell you about which character set the font supports, however. Character sets and fonts are two separate things. Perhaps there's a few bits in a font file that determine which charset a font supports, but I'm not aware of any.
The only way to tell is to either try drawing a character from that charset using that font and see if it works, or create some sort of font driver that lets you dig into the actual font data, which would be quite a feat since you need to somehow use the font handle to get the actual font file and examine the structure. Also keep in mind that there's many different types of font files, so this would be a very difficult task.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Is it possible to add our own attribute / events to web control (if it is not supporting) to increase functionality
|
|
|
|
|
|
Hi
How v can Invoke the methods that r declared in an a project(Dll) which is loaded dynamically into our project?
Is the MethodInfo class's Invoke methoda will do the job?
What does the first parameter in the second overloaded method of "Invoke" mean?
Pls help me with sample codes!!
|
|
|
|
|
|
Hi, i wanna know how can i get a cookie
for example:
mypage.com/login.html
This, have a form to login, so:
mypage.com/login.html?user=teste&pass=test
Will login with User= teste and Pass = test
Im just trying to get the COOKIE, provided by login.html after the login.
What can i use?
Thanks
|
|
|
|
|
First of all, this really belongs in the Web Developer forum. This forum is for questions relating to C#, which can be used to create ASP.NET web applications that parse, compile, and execute code on the server so format and stream HTML to (and other files) to the browser or other client application using HTTP.
Second, if you want to use ASP.NET, then by default the pages use the .aspx extension, not .html.
Third, by using .html extensions, you are implying that you want to do this using client-side scripting, since .html is, by default, not a CGI-parsed extension on any system without actually remapping file extensions.
Fourth, are you kidding? Passing the username and password in a query string is the most insecure method ever conceived! You might as well eliminate authentication. You pass username and passwords using POST (not GET) and you should use SSL over HTTP (HTTPS) if this is sensitive information. Even without using SSL, using POST at least doesn't store the username and password in the browser's history like this would.
After taking all that above into account, how you do this depends on what server you're using and lots of other information. Again, I suggest you ask this in the Web Developers forum.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Well, u dont understand...
I trying to acess a protected page with HttpWebRequest...but i need get the cookie first, to put in the CookieCollection :\
|
|
|
|
|