is there's a way to use flash file inside WPF c# application with Transparent back ground ? i tried this
public Form1()
{
InitializeComponent();
getdata();
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
axShockwaveFlash1.Movie = #"c:\users\ahmed\documents\visual studio 2013\Projects\WindowsFormsApplication1\WindowsFormsApplication1\loading10.swf";
axShockwaveFlash1.Play();
}
and this
axShockwaveFlash1.BackgroundColor =0;
and many below ! any idea ? i still get back color behind the file .
You can't do it by code at runtime.
Solution : Set (WMode) transparency via menu in the component settings (in Designer).
Find similar options to as shown in VB picture below:
Related
I'm developing a simple application. I got two projects in the solution
1 WPF Custom Control Library
2 Windows Forms Application
I'm rendering some 3D visualization on WPF and I got that embedded in the windows form as UserControl. So here is what I need to do in this project.
I've got
public void BuildObjectTest(InsertionPoint insertionPoint, Points point) that visualize one object.
Anyway I want it multiple times from my windows Form application because I need to show several objects. I've got a textbox that when I write "barcode" I've got several object items in a LIST that show some label information and buttons PREVIOUS and NEXT. So I have to think in that way is it possible to add code in the constructor runtime or is there any other way I can do that?
This is how the constructor looks like:
public UserControl1()
{
InitializeComponent();
InsertionPoints insertionPoint=new InsertionPoint(0,50,48);
Points points=new Points(100,50,20);
BuildObjectTest(insertionPoint,points);
VisualizeBoxSides();
}
To update UI in WPF Form, I had to use:
userControl.Dispatcher.Invoke(() =>
{
userControl.BuildObjectTest(insertionPoint,points);
});
I want to create a ToolStripDropDownButton which looks like the below image
But when I tried to search for ToolStripDropDownButton control in the Toolbox I was unable to find it because, after some googling, I found out that it is a class not namespace.
Then I googled out the code below
ToolStripDropDownButton dropDownButton1 = new ToolStripDropDownButton();
ToolStripDropDown dropDown = new ToolStripDropDown();
dropDownButton1.Text = "A";
dropDownButton1.DropDown = dropDown;
dropDownButton1.Height = 200;
dropDownButton1.Width = 200;
Set the drop-down direction.
dropDownButton1.DropDownDirection = ToolStripDropDownDirection.Left;
// Do not show a drop-down arrow.
dropDownButton1.ShowDropDownArrow = false;
Controls.Add((Control)dropDownButton1); //Doesn't work
But the last line of code is not valid and gives runtime error
Cannot convert type 'System.Windows.Forms.ToolStripDropDownButton' to
'System.Windows.Forms.Control'
Can someone tell me how to add such a button in C# Windows Form or what am I missing in the code?
Platform : VS2008 Express (i know it's old)
The error message says that ToolStripDropDownButton is not a Control and thus, you can't add it to your form directly.
ToolStripDropDownButton and other tool strip items only work as a part of a ToolStrip. So, you need to put a toolstrip on your form, then you can add items to it.
Code example, if you want to do it programmatically:
ToolStrip toolStrip = new System.Windows.Forms.ToolStrip();
toolStrip.Items.Add(dropDownButton1);
Controls.Add(toolStrip);
It looks like your code comes from ShowDropDownArrow example on MSDN. Check out the complete code.
Also, you can do it in a form designer in Visual Studio. Look for ToolStrip in a toolbox.
Relevant links:
MSDN: How to: Create a Basic Windows Forms ToolStrip with Standard Items
Using the Designer
MSDN: How to: Add ToolStrip Items Dynamically
C# Corner: ToolStrip in C#
StackOverflow: Windows.Forms button with drop-down menu - discussion of alternative ways to implement this kind of control. One of the answers suggests to use a standalone ToolStrip.
First off, I'll explain my program.
I have one winform that I use as my control panel. From here I have the ability to take a screen shot of my desktop using the mouse to define the area. Much like how the snipping tool works within windows.
The screen shot is generated using my screen shot class which is ran by another form called Form1. This second form has no other code in it but is simply used to generate the rectangle the screen shot will use. From here, the taken screen shot is stored in the clip board and passed back to my Screenshot class.
Now, from here what I want is a picture box in my control panel to display this taken image. Exactly like how the snipping tool works. However, the code I have wrote to pass this image to the control panel from the screen shot class complains that the event handler is always returning as null.
The code I have wrote for this is as follows:
Image img = (Image)bitmap;
if (OnUpdateStatus == null) return;
ProgressEventArgs args = new ProgressEventArgs(img);
OnUpdateStatus(this, args);
I've tried commenting out the if statement but then the processing OnUpdateStatus throws an exception saying it no longer exists.
Now, in my control panel form I am trying to grab that image and display with the following code:
private ScreenCapture _screenCap;
public ControlPanel()
{
InitializeComponent();
_screenCap = new ScreenCapture();
_screenCap.OnUpdateStatus += _screen_CapOnUpdateStatus;
}
private void _screen_CapOnUpdateStatus(object sender, ProgressEventArgs e)
{
imagePreview.Image = e.CapturedImage;
}
I've spent hours on this but i cannot work out why the image won't display in the image box on my ControlPanel. Can anyone with a fresh set of eyes help me out? Why is it the screen shot image I take, isn't being displayed in my picture box held on my ControlPanel?
This is the problem, I think (there's a lot of code to skim through - a short but complete example would have been better):
ScreenCapture capture = new ScreenCapture();
capture.CaptureImage(...);
That's a new instance of ScreenCapture. It doesn't have any event handlers attached to it (which is why you're seeing a value of null for OnUpdateStatus. If you want to use the instance that you've created in the ControlPanel class, you'll want to pass that to your Form1 (e.g. in the constructor).
I'm working on a project and I need to embed a PowerPoint viewer in windows forms. I'm using the following activeX control: http://www.daolnwod.com/free-powerpoint-viewer-activex.html.
I activated the control to be used with the form designer's toolbox and dragged it into my form. I then edited the code in the InitializeComponent() method to the following:
this.axPowerPointViewer1 = new AxPOWERPOINTVIEWERLib.AxPowerPointViewer();
((System.ComponentModel.ISupportInitialize)(this.axPowerPointViewer1)).BeginInit();
this.axPowerPointViewer1.Enabled = true;
this.axPowerPointViewer1.Location = new System.Drawing.Point(0, 0);
this.axPowerPointViewer1.Name = "axPowerPointViewer1";
this.axPowerPointViewer1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axPowerPointViewer1.OcxState")));
this.axPowerPointViewer1.Size = new System.Drawing.Size(925, 573);
this.axPowerPointViewer1.TabIndex = 5;
//this.axPowerPointViewer1.CreateControl();
this.Controls.Add(this.axPowerPointViewer1);
((System.ComponentModel.ISupportInitialize)(this.axPowerPointViewer1)).EndInit();
And in my Forms constructor
public Form1()
{
InitializeComponent();
axPowerPointViewer1.Show();
bool loaded = axPowerPointViewer1.LoadFile(#"C:\Debug\test2.ppt"); // loaded = false
string z = axPowerPointViewer1.GetSlideCount().ToString();
}
However, when I'm opening the form nothing shows up. The code compiles but I can't see my test slide that I've been working on. I have created 2 buttons for 'Previous' and 'Next' slides but debugging gives me a slide location of 0 every time so something must be wrong and I can't seem to find it.
UPDATE
The problem has been solved. It seems I didn't call axPowerPointviewer1.InitControl(). It still has a few troubles, sometimes it won't display the first slide at startup. If things keep running smoothly I'll post an answer to this problem.
The problem is in initialising the control. In order for the control to fully function you need to call the InitControl() method so call calling the following code should make the program work:
private void Form1_Load(object sender, EventArgs e)
{
this.axPowerPointViewer1.InitControl();
}
I noticed that adding a MenuStrip (from the Toolbox) to my form design doesn't yield a menu bar like the one seen in many native Windows applications. Instead I get a menu bar like Visual Studio's own. None of the style settings for MenuStrip appear to mimic the much more common native menu bar.
Is there a way to add a menu bar to my Windows Forms application that looks the same as the one you see in Notepad, Task Manager and others? (Preferably with the designer, but I wouldn't mind adding it programmatically either.)
Screenshot for illustration:
Go to your Toolbox, right click anywhere inside and select "Choose Items".
When the dialog loads and appears, scroll down til you see MainMenu. Add that to the toolbox, and you've got yourself a native menu bar!
You can do this by setting your form's Menu property, like this:
private void Form1_Load(object sender, EventArgs e)
{
this.Menu = new MainMenu();
MenuItem item = new MenuItem("File");
this.Menu.MenuItems.Add(item);
item.MenuItems.Add("Save", new EventHandler(Save_Click));
item.MenuItems.Add("Open", new EventHandler(Open_Click));
item = new MenuItem("Edit");
this.Menu.MenuItems.Add(item);
item.MenuItems.Add("Copy", new EventHandler(Copy_Click));
item.MenuItems.Add("Paste", new EventHandler(Paste_Click));
// etc ...
}
private void Save_Click(object sender, EventArgs e)
{
// save
}
These menus will look like "normal" system menus.
I couldn't find any designer support for this, though. In my defense, I didn't try real hard.
Instead of using a the MainMenu component you can create your own renderer for the MenuStrip component. The advantage here is being able to add images to MenuStripItem objects. Here is the pastebin for the custom renderer:
NativeRenderer
There are different themes that can be applied in the constructor of the renderer. Try them all to see the native themes. To use this renderer simply set the instance to the MenuStrip Renderer property:
menuStrip.Renderer = new NativeRenderer([theme]);
I normally set the MenuStrip's RenderMode to System which gives a minimalist, single colour menu (no gradients or anything decadent like that).
If that does not go far enough, then you'll likely have to jump through some low-level hoops to get what you want.