|
Hi ,
For my windows app, i stored my connection in application settings i.e. project > properties> settings tab.
Now i need to access the connection string from code
any help is appreciated,
yojimbo
|
|
|
|
|
I'm trying to create a structure that contains an array of another structure within it and keep getting compile errors: Here's what I'm trying to do:
public struct MyState
{
int Id;
byte state;
}
// This gives me a compile error - cannot have instance field initializers in struct
public struct MyArray
{
MyState[] state = new MyState(100);
}
so I tried this - Gives me a compile error also
// fixed size buffer must be one of the following int, bool, etc...
public struct MyArray
{
fixed MyState state[100];
}
Any ideas - I'm receiving a message from a legacy system that has the message format wired to a specific byte layout.
Kim
Kim Ferrari
|
|
|
|
|
MyState[] state;
is an array reference; it will start life with the value null ( compare to TextBox tb; )
You can assign something to it with code within a method, or as an initializer if
it is a member of a class, but not in a member of a struct (struct members dont take
an initializer)
In a struct, you should use a constructor if you need some data to be initialized inside
the definition of the struct.
So you could write:
public struct MyArray {
MyState[] state;
public MyArray() {
state = new MyState[100];
}
}
and there are some variations, you could get the size as a parameter in the constructor,
or you could create (=call new) the array at a later point in time, i.e. within the
code that uses your MyArray.
Luc Pattyn
|
|
|
|
|
Thanks!
Kim
Kim Ferrari
|
|
|
|
|
Hi,
I'm trying too add MouseClick event or any event on WIA video stream overlay.
WIA video is previewed in window form which has registered events. But events aren't triggered when mouse is over WIA video overlay.
Overlay is previewed in the form like this:
wiaVideo = new WiaVideoClass();
wiaVideo.CreateVideoByWiaDevID( wiaDeviceID, window.Handle, 0, 1 );
How can I catch MouseClick Event over wiaVideo?
Thanks
|
|
|
|
|
If your WiaVideoClass has an Enabled property and your app functionality allows it, try
setting it false, so the mouse events go to the underlying control.
Luc Pattyn
|
|
|
|
|
Thanks for the quick answer,
but WiaVideoClass does not have Enabled property. I'm wondering is this possible to do without any involvement of WIA object (just by using underlying control)?
|
|
|
|
|
OK.
Please tell more about WiaVideoClass (purpose, origin, source available, does it need
user interaction, etc).
Luc Pattyn
|
|
|
|
|
Thanks for trying to help!
Video overlay is placed in the Control like this:
wiaVideo = new WiaVideoClass();
wiaVideo.CreateVideoByWiaDevID( wiaDeviceID, window.Handle, 0, 1 );
WiaVideoClass looks like this:
namespace WIAVIDEOLib
{
[Guid("3908C3CD-4478-4536-AF2F-10C25D4EF89A")]
[TypeLibType(2)]
[ClassInterface(0)]
public class WiaVideoClass : IWiaVideo, WiaVideo
{
public WiaVideoClass();
[DispId(2)]
public virtual string ImagesDirectory { get; set; }
[DispId(1)]
public virtual int PreviewVisible { get; set; }
public virtual void CreateVideoByDevNum(uint uiDeviceNumber, IntPtr hwndParent, int bStretchToFitParent, int bAutoBeginPlayback);
public virtual void CreateVideoByName(string bstrFriendlyName, IntPtr hwndParent, int bStretchToFitParent, int bAutoBeginPlayback);
public virtual void CreateVideoByWiaDevID(string bstrWiaDeviceID, IntPtr hwndParent, int bStretchToFitParent, int bAutoBeginPlayback);
public virtual void DestroyVideo();
public virtual WIAVIDEO_STATE GetCurrentState();
public virtual void Pause();
public virtual void Play();
public virtual void ResizeVideo(int bStretchToFitParent);
public virtual void TakePicture(out string pbstrNewImageFilename);
}
}
Whole example is from here:
http://www.codeproject.com/dotnet/wiascriptingdotnet.asp?df=100&forumid=3908&exp=0&select=945495
Thanks again!
|
|
|
|
|
Hi guys, I have a small app which contains 3 forms. Within each form form_load method I am setting threadign sleep to 1200. All I want to do is how can i display a progress bar after each formload is done.
Can somebody how me or provide some examples
Thanks
|
|
|
|
|
Why would you sleep the thread ? If the thread is sleeping, it can't run anything. You'd need to do it differently
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I have seen some applications like photoshop as soon as you open they have a screen and that stays till the whole app is loaded. I want to do something like that too.
so let's say in my form i am trying to open a notepad application while the system is loading i want to display a progress bar based oh how much it has been loaded. I want to build something like that.
Thanks
|
|
|
|
|
OK, well, that's different. I create a splash screen as a form, make a static instance of it, and create/show it as the first step in my app. If I had a progress bar on there, I'd expose a method to step the bar, and call it as key steps in my loading process occured.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Could you please show some example for my better understanding.
|
|
|
|
|
The most striking word in Christian's reply was "splash". Dit you search for it on
CodeProject ? This site has thousands of articles, some are dealing with your problem,
I'm sure.
Luc Pattyn
|
|
|
|
|
At it's most obvious, create a form that has a progress bar in it, and a public method called Step() which moves the progress bar forward. Call it SplashDlg.
In your main form class make it a variable:
public static SplashDlg splash;
As early as you can in your code, create it:
splash = new SplashDlg();
splash.Show();
where-ever your program progresses in the things it has to do to load, call this:
splash.Step();
Work out how many steps you take and set the progress bar to have that many, and you're done.
OR, as Luc said, take the word 'splash' as a clue on what to google for more info.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
How can I get the mouse position from desktop?
thank you
|
|
|
|
|
Control.MousePosition gets the position of the mouse cursor in screen coordinates.
Luc Pattyn
|
|
|
|
|
In C#:
I am building the MessageBox parameter:
MessageBoxButtons.OK
from a string. The string is defined this way:
string buttonSelected = “MessageBoxButtons.” + selectedButton;
selectedButton is defined elsewhere in the program, lets say as “OK”.
When I call MessageBox, I try to cast the parameter MessageBoxButtons like this:
MessageBox.Show(“test”,”test”, (System.Windows.Forms.MessageBoxButtons) buttonSelected);
I get an error that says I cannot convert type string to System.Windows.Forms.MessageBoxButtons.
Why can’t I do this?
Vern
|
|
|
|
|
In general you can not cast a string to just any kind of object you are dreaming of.
You can do the opposite, that is each kind of object has a ToString() method (inherited
from Object) to give you a string representation (although the default implementation returns
simply the type name, not always very useful; but you can and should override the ToString
method).
If you want to communicate about message buttons between different pieces of code,
you should use a variable of type MessageBoxButtons.
Example:
MessageBoxButtons myButtons;
bool withCancel=false;
if(withCancel) myButtons=MessageBoxButtons.OKCancel;
else myButtons=MessageBoxButtons.OK;
... whatever other things you want to do
MessageBox.Show("text", "caption", myButtons);
Luc Pattyn
|
|
|
|
|
Luc:
Thanks for the response. I did finally end up using some code that used MessageBoxButtons and MessageBoxIcon variables.
Thanks again.
Vern
|
|
|
|
|
You can use enum.Parse to turn a string into an enum instance
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Christian:
Thanks for you response. The enum.Parse was a good tip.
Thanks again.
Vern
|
|
|
|
|
Hey i have a datagrid that when a mouse is moved in the cell it is supposed to display the tooltip with information for some reason it isn't working. i tested it on a textbox and it works fine. But with the datagrid it is giving me major problems below is what i have
private void dgvCreditCards_CellMouseEnter(object sender, DataGridViewCellEventArgs e)
{
ttInformation.SetToolTip(dgvCreditCards, "Help Me");
ttInformation.Active = true;
ttInformation.Show("This is a test", dgvCreditCards, e.RowIndex, e.ColumnIndex);
}
i even created the popup event for the Tooltip and set a break in it and it is actually catching. for whatever reason it just isn't working. Anyone know what i'm doing wrong?
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
If I remember correctly, there recently has been a discussion thread on a tooltip
that varried with the cells of the DataGridView. So I suggest you use the magic
"search comments" button with the appropriate keywords.
Luc Pattyn
|
|
|
|