|
There is no dotnet installer. VS.NET uses Windows Installer, which is used to install Microsoft Office, Microsoft Visual Studio, Microsoft .NET, our own products, and thousands of other products.
You can write custom actions and even custom user interfaces, though VS.NET will help you very little. If you want control, get a third-party Windows Installer developer environment like Wise for Windows Installer[^].
With VS.NET, all you could really do is add a new dialog (play around with the Installer projects in VS.NET or read about it - you'll never learn any other way).
You could then make a custom action bey extending the Installer class in the System.Configuration.Install namespace. Compile this into an assembly along with the ADO.NET code (preferably in a single assembly) and add it as a custom action in the Custom Actions panel of the Windows Installer project (use the menus to find it). Pass properties from the dialog you've added to the installer class as command-line switches (/SomeSwitch=[PropertyName] /SomeSwitch2=[PropertyName2], etc.) where PropertyName is the name of hte property you associated with the text box for the dialog you created.
In your Installer derivative class, you can get these using the Context property you inherit to get the Parameters property, which is a StringDictionary of command line switches and values.
You must read about this information to understand it. There's a lot to cover and I won't waste my time answer questions that are answered in the .NET Framework SDK about the classes I've mentioned. I'm telling you one way you could do this and giving you plenty of reference material.
Finally, another way you could accomplish this is to simply prompt for this information when the application is first run. Check a registry key you define (like HKEY_CURRENT_USER\Software\YourCompany\YourProduct\Init). If the key doesn't exist or isn't 1 (for example), then prompt for the information. After adding that information in whatever manner is appropriate, set that registry key to 1 (so the user won't be prompted again). This is a very common approach, an approach that even Microsoft Office has used since Office XP for activation (though it's not as simple as a single registry key; the concept is similar, however).
Some third-party .NET controls work this way as well, prompting for license information the first time the designer is invoked or something similar.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
The bitmap constructor throws an InvalidArgumentException, if I try to create a bitmap like this:
Bitmap bitmap = new Bitmap(23622, 18897, System.Drawing.Imaging.Pixelformat.Format24bppRgb)
But this works:
Bitmap bitmap = new Bitmap(23622, 18897, System.Drawing.Imaging.Pixelformat.DontCare)
Can somebody please explain, what the problem is with Format24bppRGB ?
Best regards
-------------------------------------------
The light at the end of the tunnel has been switched off temporarily due to budget problems...
|
|
|
|
|
Pain,
It's the numerical values, they must be invalid for creating a 24bit bmp.
If you change them, say 1,1 then it works just fine.
Hope that helps
Kev Pearman MCP
|
|
|
|
|
The problem is that your image, at 23622 pixels wide and 18897 pixels high, and 24bpp, is about 1.3GB in size. If you don't have the memory to hold such a huge image, you'll get InvalidArgumentException's.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dear CPians,
I want to hide RichtextBox's ScrollBar or set its width = 0, since I am scrolling the RichtextBox programetically in runtime using API methods (SetScrollPos , GetScrollPos , PostMessageA ).
How to achieve this?
Thanks in advance,
Regards,
Jay.
|
|
|
|
|
What about the RichTextBox.ScrollBars property!? MSDN[^] says "You can also use this property to remove scroll bars from the control to restrict scrolling the contents of the control."
|
|
|
|
|
This would not solve my purpose.
Actually I want to syncronise the scrolling of two RichTextBoxes ,
say RichTextBox1 and RichTextBox2
I am overriding WndProc method of RichTextBox1 and sending System.Windows.Forms.Message m to RichTextBox2 by raising an event and passing m.WParam , m.LParam .
If I set RichTextBox2.ScrollBars = None , the above would not work.
|
|
|
|
|
What does synchronization have to do with "How to Hide ScrollBar of RichtextBox", which is what your subject says? The first reply answered your subject.
You don't pass a Message to WndProc . The RichTextBox encapsulates the Rich Edit common control, which manages the scroll bars itself. You only need to P/Invoke SendMessage (or SetScrollPos , as you asked about before) and set the scroll position. This results in the scroll messages being sent and the scroll bars adjusted automatically, all something done by the Rich edit control.
The only reason to override WndProc is to handle the WM_HSCROLL (0x0114) and WM_VSCROLL (0x0115) messages. As documented in the Platform SDK, the high-order word is the actual position, where the low-order word is the scrolling request. You should read the documentation for these two messages (though they are alike) in the Platform SDK on MSDN[^].
What you then do is call the P/Invoke'd SendMessage (see pinvoke.net[^] if you need help with the signature) with the same message (WM_HSCROLL or WM_VSCROLL ) and the same parameters. Do not call WndProc directly. SendMessage (or use PostMessage for asynchronous operations, which should work in most cases) does this.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Dear Heath,
I am doing the same. Please refer to the code below:
protected override void WndProc(ref System.Windows.Forms.Message m)
{
if(m.Msg == WM_MOUSEWHEEL)
{
if(Control.ModifierKeys != Keys.Control)
{
MouseWheelRollingEventArgs e = new
MouseWheelRollingEventArgs(m.WParam, m.LParam);
MouseWheelRolling(this, e);
base.WndProc(ref m);
}
else
{
return;
}
}
else if( m.Msg == WM_VSCROLL )
{
base.WndProc (ref m);
}
else
{
base.WndProc (ref m);
}
}
private void rtb_MouseWheelRolling(object sender, TextEditor.MouseWheelRollingEventArgs e)
{
const int WM_MOUSEWHELL = 0x020a;
PostMessageA((int)lineSrNo.Handle,WM_MOUSEWHELL, (int) e.wp, (int) e.lp);
}
rtb and lineSrNo are the two richTextBoxes , I want to syncronise.
lineSrNo richTextBox contains the lineNumbers of rtb richTextBox .
When ever user scrolls the rtb richTextBox (using MouseWheel rolling or ScrollBar ) correspondingly lineSrNo richTextBox should also get scrolled.
Line numbers are added in the lineSrNo richTextBox when ever user enters any line in rtb richTextBox .
lineSrNo richTextBox Locked property is set to True and I am scrolling it programetically.
I am able to acheive the target, but I do not want scrollBar in lineSrNo richTextBox
That is the reason, I am asking the way out to hide the scrollBar of the richTextBox or set its width to 0.
Regards,
Jay
|
|
|
|
|
Have you tried getting the handle to the scroll bars (use FindWindowEx , or some controls actually define a message to return the scrollbar handle) and simply P/Invoking SetWindowsLongPtr passing ~WS_VISIBLE OR'ed with the previous style? That would literally hide the scrollbars but should still respond to scroll messages.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I tried getting the Handle of richTextBox's scrollBar using the following code, but could not succeed. Can you please point out where am I going wrong?
public class ScrollBarHiddenRTB : System.Windows.Forms.RichTextBox
{
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern IntPtr FindWindowEx(IntPtr parent, IntPtr next, string sClassName, IntPtr sWindowTitle);
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern int SetWindowLongPtr( IntPtr hWnd, int nIndex, int dwNewLong);
private const int WS_VISIBLE = 0x10000000;
public ScrollBarHiddenRTB() : base()
{
this.HandleCreated += new EventHandler(CreateRTBHandle);
}
private void CreateRTBHandle(object sender, EventArgs e)
{
ScrollBarHiddenRTB self = sender as ScrollBarHiddenRTB;
System.Diagnostics.Debug.Assert(self != null);
IntPtr scrollHandle = FindWindowEx(self.Handle, IntPtr.Zero, "ScrollBar", IntPtr.Zero);
if(scrollHandle != IntPtr.Zero)
{
MessageBox.Show(scrollHandle.ToString());
}
}
}
Regards,
Jay.
|
|
|
|
|
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...
|
|
|
|
|