Diamonddrake 397 Master Poster

there is a couple ways to do this, the way photoshop does it is drawing to the screen... not the form. here is an example of doing so

using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;

namespace DrawToScreen
{

#region UnmanagedMethods
internal class UnmanagedMethods
{

[DllImport("user32")]
internal static extern IntPtr GetDC(IntPtr hwnd);

[DllImport("User32.dll")]
internal static extern void ReleaseDC(IntPtr dc);

}
#endregion

#region Actual drawing

public class DrawingToScreen
{
public void PaintRectToScreen()
{
IntPtr deskDC = UnmanagedMethods.GetDC(IntPtr.Zero);

Graphics g = Graphics.FromHdc(deskDC);

g.FillRectangle(new SolidBrush(Color.FromArgb(100, Color.Green)), 0,0, 500, 500);

g.EndContainer(cont);

g.Dispose();

UnmanagedMethods.ReleaseDC(deskDC);
}
}
#endregion
}

Not sure where I got it. Kudos to whoever wrote it.

this method works well, but only if you are sure to draw to the screen over your application only, because the desktop will not be invalidated when you expect, so clearing the image won't always go so hot. Its complicated.

A different... yet equally complicated, but less buggy method would be to create a new form, chromeless, that uses exlayerdwindow to display a slightly transparent image following the mouse. this would be much easier to accomplish the look you want, since the form will support full transparency you could make it look however you wanted, even create the image prorammatically in GDI plus, if you wanted too....

either way, Concepts such as though are very complicated, and the simple things like that are truly the hardest features.

Best of luck.

Diamonddrake 397 Master Poster

First create some variables to hold your sound objects, you want them to have a full scope so create them directly in the class.

protected IrrKlang.ISoundEngine irrKlangEngine;
		protected IrrKlang.ISound currentlyPlayingSound;

then in the form's constructor initialize the the sound engine.

irrKlangEngine = new IrrKlang.ISoundEngine();

then in the load event or a button or whaver you want it to start use

currentlyPlayingSound = irrKlangEngine.Play2D(filenameTextBox.Text, true);

            currentlyPlayingSound.PlayPosition = //how ever far you want it to start;

just play with the properties of the sound object to manipulate its volume, play position, play length. ect. ect. ect.

Diamonddrake 397 Master Poster

http://www.moddb.com/engines/irrlicht-engine/downloads/irrklang

Download this free player engine for .net Its not big, comes will a million examples, plays about anything, anyway you want it. even allows for easy 3d sound too. Check it out!

Diamonddrake 397 Master Poster

Creating images and loading them you will notice you will either have to include the images as resources, or as files along with your program. Its a lot of trouble, you won't get good results. especially when the control is resized. or if you have non rectangular controls.

Drawing the control by overriding the onPaint method of a control and using gdi is the best way to go about it, as the examples shown before from sknake and dan.

Diamonddrake 397 Master Poster

what is this webin object that is used to load the html? It seems to be already created before the function that calls the print. you could try creating it loading, printing, then disposing that object. Its likely that its still treating the file like its still in use even though you call its own method that seems to navigate away.

Just a though, if you haven't tried that yet.

Diamonddrake 397 Master Poster

The code ramy posted was sound. It had a little left to chance, but I don't see how anyone could have a problem with it.

I have included an example project, just compile it and click the button, then go back and read the code.

all credit to this code goes to ramy, I just copy and pasted it in, then modified it slightly to be more obvious in what was what.

Ramy Mahrous commented: Thanks :) +7
Diamonddrake 397 Master Poster
private void safetipsbtn_Click(object sender, EventArgs e)
        {
            mainpage mp = new mainpage();
            this.AddOwnedForm(mp);
            
            safetips safe = new safetips([B]this[/B]);
            safe.Show();
            internetsitebtn.Enabled = false;
            howtousebtn.Enabled = false;
            adminpanelbtn.Enabled = false;
        }

then modify the safetips constructor

Form MP;//hold main form instance
public safetips(Form MMP)//this is the safetips constructor
{
MP = MMP;
}

now you can reference any public member on the first form from the safetips form by useing the form instance variable "MP" we just created. example.

MP.[I]buttoncontrol[/I].Enabled == True;

do that for all your buttons in the on closing even and you will get your desired effect.

Sorry its so concise. its late and I am tired of typing. Good luck.
Happy coding.

Diamonddrake 397 Master Poster

it very well might be that when the cursor is blinking in the box, that it causes a problem, how about in your delegate the first thing you do is change the focus. just fall object.Focus(); on anything else. most likely the button. which would be a good practice anyway since when a button is clicked it leaves a focus ring around itself, this would make it clear to the user that the update occurred, just as if the button was pressed.

Its likely the problem, and its all I can think of with only that information. Just give it a try. I bet you'll be surprised!

Diamonddrake 397 Master Poster
public partial class menuBienvenida : Form
{
private short counter=0;
public short _counter
{
get
{
    return counter;
}
set
{
     counter = value;
}
}
private void botonNuevo_Click(object sender, EventArgs e)
        {
if(counter==0)
{
            principal principalForm = new principal(this);
            principalForm.Show();
            counter++;
}
else
         MessageBox.Show(...);
        }
}

then in principal form mod the constructor to keep track of the main instance.

public partial class principal : Form
{
     Form mMain;
     public principal(Form F);
{
        mMain = f;
       
}
   //create an event handler for on close
   private void principal_onClose(Object sender, EventArgs e)
{
  mMain._counter = 0;
}
}

best of luck.

Diamonddrake 397 Master Poster

you need to pass the instance to the constructor of the new form modify the constructor to take a form type variable and assign it to a local variable. like so.

on the job form

Form MainForm;

JobForm(Form MFrm)
{
    MainForm = MFrm;
}

then you can use the "MainForm" variable to get the properties of the main form.

now be sure to pass the instance to the new jobfor using the "this" keyword when instantiating the new form.

JobForm jbf = new JobForm(this);

and that is all you need to know. there is another way, because of the way that the dot net framework works, there is a way to call the clr and get a list of all the public objects open and search for one with the correct name and type, but its complicated, and the best way is that in which I already shared.

happy coding.

Diamonddrake 397 Master Poster

Im not sure that this question has to do with threading at all... it seems you need to create a custom event in your panel that your form subscribes to. that just tells the from that its done calculating, and just move the code from your FORM's click event handler to the custom event handler method on the form that handles the custom event that is fired when the panels mouse click events code is finished. easy huh lol. Im not 100% on how your code works, so the code I am posting is for referenced only. I can't garantee you can just past it in to get the desired effect. but then again. it will probably work fine.

so in the PANEL you would create a custom event like so

//create delegate for event
        public delegate void panelClickerHandler(object myObject,
                                     EventArgs myEvent);
       //expose delegate for subscription
        public event panelClickerHandler OnPanelClicker;

and add a event throw at the end of your click event.

private void MapEditorPanel_MouseClick(object sender, MouseEventArgs e)
        {

            Point mapCoordinates = getMapPointFromScreen(e.Location);
        
            Tile tileClicked = map.getTileFromPoint(mapCoordinates);

            activeRow = (tileClicked.Row);
            activeColumn = (tileClicked.Column);

             //throw event to notifiy subscribed objects that we are 
             //done here

              OnPanelClicker(this, EventArgs.Empty);
        }

ok. so now we need our FORM to be subscribed to that event. and its clicked event should not be used in this case(I think, im not all that sure how your appy works.)

so we subscribe to the event.

//as I am unsure of your panel instance …
Diamonddrake 397 Master Poster

you could create a dummy file, a little text file or something that serves no purpose but to encourage the creation of the folder, but other than that, you might just have to wait for a new version of VS to fix that.

Diamonddrake 397 Master Poster

If you just want to copy an empty folder, it won't work, but if the folder contains files, you can right click in the soution and click create new folder, then copy your files in explorer to that new folder in your project directory, then go back to your solution and right click on the folder and click add existing, then select the files that are already in that folder, this will add them to your solution under that folder, expand it and select them, you get the copy to output option then, and if you choose to always copy, then it will create the subdirectory and fill it with the files.

Diamonddrake 397 Master Poster

copy to output directory just makes a copy of the selected resource where the program is compiled to. It has no real significance other than keeping you from having to manual find and copy files to a single location.

if you need a sub directory in the same directory as your application. you are best off checking if it exists, and if not, creating it programmatically. Its simple and effective.

Diamonddrake 397 Master Poster

save as should do it, if it doesn't work then there may be a problem with your links. But as for quicktime playing your media, its because its the default plugin. open the options menu in firefox and click the applications tab. a list of web file types will appear with the codec that will play them. simple browse for mp3 file format, and change its default behavior to "always ask" and it will ask if you want to play it, or download it. respectfully everytime.

best regards.

but also. I don't think this post belongs in this thread of the IT forum. Be careful where you post your questions.

Diamonddrake 397 Master Poster

I have posted an example of what I was talking about, I just used that codeproject alphablendform and created a form that inherits from it, used a mousemove to set its position. But inorder to pass the click from one form to another, I had to use a mouse_event interlop to tell windows to release, then click again, without you actually have to do so. I added a picture box, set an image to it, then used some basic stuff to set the positon of the new form over the old text box, told it to create a thumbnail form the image, just incase its a zoomed picture, set the size of the new form to the size of the text box, set the dpp of the image to match requirements, and used bitmap.maketransparent to ensure it has a transparent region require for such a thing, this could all be done a better way, and is not error proof, its all just poped in for sake the demonstration.

the VS2008 project I included has the "debug" prebuilt in the bin folder, give it a try, just click and drag the image I included of a cupcake, it will pop out, be lightly transparent, I used 200 out of 255. and it will follow the mouse til you let go, in which case it just closes the new form. but you can do whatever you want, have it call a function in the main form passing where the mouse was …

ddanbe commented: Thanks for the effoet you put in! +6
Diamonddrake 397 Master Poster

If you are looking for that firefox style drag image, where a "ghost" like copy of the image moves about the screen. I believe a good way to go about it is on drag, to create a new form, topmost, that's window property is set to none, and just set its size to the picture's size, draw the image on it. and have it move with the mouse until the mouse is released, you will get a nice floating image, that can move over anything on the form and even off the form if the use decides to drag the mouse that far. And if you really want a good effect, use a layeredwindow, since you need no controls drawn on it, just an image, it would be an easy fitting solution that would allow for nice transparency so the users could see what's under the image, and also still see the image they are dragging.

not to say that's the best method.

alternatively, to get a copy of the image to drag just across the form, you would need to create a new instance of the control, with the same attributes and have it move, and the other control would have to stay put.

If you want a good look. although it would be very complicated. My first suggestion of a new form, would probably be best. here is an example of what i mean

http://www.codeproject.com/KB/GDI-plus/perpxalpha_sharp.aspx

Happy Coding

Diamonddrake 397 Master Poster

here it is, this, being a modified version of a code project has only the original license, I choose not to add any additional licenses.

I wish you the best in your programing endeavors, and please do remember to mark this thread as solved when you are satisfied.

Happy coding

Diamonddrake 397 Master Poster

ok, I have edited the example that comes with the download you linked me to to support a background thread that supports cancellation. It works perfect. Turns out with that code several things had to be done, the whole framegrabber object needed to be created in the new thread,(which is what I was trying to get at before) also the paths needed to be passed to the thread by and object. the preview image needed to be passed as a progress object argument and set via the progressed changed event. a check had to be added to the loop that extracts the frames to check for a cancellation. and since cancel and grab will never need to be pused at the same time, I simply added a switch to make them the same button.

This is the entire class from the project edited. replace the entire class in your project with this one, or just edit it to match. If you have any questions just ask. remember to add a background worker and set its event handers to the ones I added to the class.

This code is tested and effective, if you need a VS2008 Example. I have it and can post the finished working code if need be.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using User.DirectShow;

namespace FrameGrabberTester
{
	public partial class Form1 : Form
	{
		//private FrameGrabber fg;
        private string pathFILE;

		public Form1()
		{
			InitializeComponent();
		} …
Ramy Mahrous commented: Done well! perfect. +7
Diamonddrake 397 Master Poster

i was just saying, in that code,
FrameGrabber.Frame and picBoxFrame.Image
both refer to objects from the originating thread. you can't access them directly from the worker thread. that's a cross thread exception.

These classes would need to be instantiated in the worker thread, or at least that is my understanding of threading. which I have used recently on 2 projects.

Diamonddrake 397 Master Poster

If Ramy's way works for you, then best of luck, but as for the original post. The problem with using the background worker was probably that whatever dll control you were using expects a drawing surface and you weren't supplying one, possible, In not familiar with this frame grabber, which makes it harder to help, more importantly the objects you were using in the background worker would have to be passed to the background workers dowork event handler via an object in the DoWorkEventArgs. So the code for your background worker is not correct.

What ever the control famegrabber is needs to be instantiated inside the dowork event handler, or a function that the event hander calls, all the code must not interact with anything from the original code. so essentially the code in the dowork event handler needs to be complete, as in like it was its own stand alone style application, so it would instantiate a new object of the control, pass to that whatever collection or file name you needed, then add that data to a new collection, or a save it to a file, then pass that info back to the work completed event via the e.Result property.

many programmers think one day they are just going to hop into multithreading applications and don't' realize how much trouble it can cause. Its actually difficult. and the .net threading class makes it almost too easy. making it seem that less is going on that actually …

Diamonddrake 397 Master Poster

flash projector is an exe that plays an embedded flash file, so yes it is. and its very simple.

there are free programs that will create a projector out of any swf file.

Diamonddrake 397 Master Poster

There is no % key, so it would be hard to find it. but what there is, would be a shift modified D5 key. So you look for a combination of those keys.

add this to your keydown event:

if (e.Modifiers == Keys.Shift && e.KeyCode == Keys.D5)
            {
                MessageBox.Show("% Key Pressed");
            }

NOTE:
for the alt or ctrl key, its not necessary to check the e.modifiers flag, but when using the shift key it is. I don't know why. I have just tried with it for a while and I ended up with this combination of event data to be the only one that worked.

But there you go, Hope this solves your problem.

Diamonddrake 397 Master Poster

you can view the same data set as many times as you want.

problem is... with only the description of the result of a problem, its hard to diagnose it... its like calling a mechanic and telling them your car doesn't work, then with only providing the detail that you tried to start it... you ask precisely how to fix it.

one problem you might have, is you should create an instance of the data adapter for both queries, one at a time setting them to null after each, its actually most simple to create a method that accepts a datagridview argument, and a sting argument. passing to it, what gridview to laod the data to, and what sql query to present to your database. then call them when you need them, in this case on form load.

or else, post you code.

Diamonddrake 397 Master Poster

Visual C# Express is free

Indeed. I can't argue with that, but still many programmers don't use Visual Studio.

Diamonddrake 397 Master Poster

only problem with this teach a man to fish deal you have running is that not everyone has Visual Studio, some people are compiling using free software with no help files, and online help from Microsoft is practically Japanese to a weekend programmer.

But I do understand, although i understand things best with an example, simply searching for an answer to this problem in google yields the exact answer in the first result by just searching "mid() in C#" http://www.csharphelp.com/archives4/archive616.html but manytimes i have been searching for some help on something and had to waste my time reading forum posts that were top search results that don't answer me at all.

so I am undecided, sometimes I just don't know where to go, and I have no code to post.

further note, that link is a good one, it shows how for someone accustomed to VB style left, mid, and right functions to reproduce them in C# so they can even still be called using left, mid, and right respectfully.

Live and Dream in code my friends.

Diamonddrake 397 Master Poster

what you have to do is remove "using System.IO;" from the top of your class, and everytime you need to use System.IO.File you will have to type the full namespace. problem is that when you import the namespace for the object that creates your shortcut you share its namespace scope with the "File" namespace scope of the System.IO, so removing the using block at the top of your class fixes the problem.

Happy Coding!