Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
E

erfi

@erfi
About
Posts
54
Topics
18
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Threading Problem
    E erfi

    hi. i have a class like this :

    public ref class MyClass : public IDisposable
    {
    .
    .
    .
    public: MyClass();
    private: void Wait();
    .
    .
    .
    }

    and the cpp file:

    MyClass::MyClass()
    {
    // Create a new thread to wait for events
    Thread^ t = gcnew Thread(gcnew ThreadStart(&MyClass::Wait));
    t->Name = "Event Thread";
    t->Start();
    }

    in compile i got this error : "error C3350: 'System::Threading::ThreadStart' : a delegate constructor expects 2 argument(s)" I've looked in msdn and saw a example that exactly used this way for threading but there was no error in compilation. thank you for help.

    sometimes 0 can be 1

    Managed C++/CLI

  • Save Paint Event of Custom Control
    E erfi

    How can i record the paint event in the custom control? if you mean that you want to save the picture of a control on paint event then maybe this help: Screen Captures, Window Captures and Window Icon Captures with Spy++ style Window Finder! WindowSnapshot - System Tray Utility To Surgically Capture Bitmaps of Windows/Controls On The Screen

    sometimes 0 can be 1

    C#

  • Form refresh... and accept click on button while performing other task...
    E erfi

    your code is too long and i haven't enough time to read it all. but below is the way to use a thread: my form has two button named "buttonStart" and "buttonStop" when i press the first one my thread starts and when press the second one my thread stops. this is my code :

    private: Thread^ myThread;
    private: static volatile bool stop;

    private: System::Void buttonStart_Click(System::Object^ sender, System::EventArgs^ e) {
    myThread = gcnew Thread(gcnew ThreadStart( &Form1::Function ));
    stop = false;
    myThread->Start();
    buttonStart->Enabled = false;
    }
    private: System::Void buttonStop_Click(System::Object^ sender, System::EventArgs^ e) {
    stop = true;
    buttonStart->Enabled = true;
    }
    public: static void Function()
    {
    MessageBox::Show("thread is now starting");
    // for example a "do while" loop
    do
    {
    // do some work
    }
    while(stop == false);
    MessageBox::Show("thread stoped");
    }

    you can add some extra controls to your form and see that when you press the start button your controls will be alive. my function has a infinite loop and if you run it without threads your UI hangs. however, i suggest you to read these: Thread Class[^] Threading tutorial[^] to get a clean understanding of threads. and there are many perfect articles of threading in CP[^]: 1 2 3 4 5

    sometimes 0 can be 1

    modified on Wednesday, March 25, 2009 5:37 PM

    Managed C++/CLI question help career

  • marking shape on image
    E erfi

    hi. i think you are looking for a template matching algorithm. there are several ways for this. but the main problem in all algorithms is the size of object. if you looking for a fixed size object then it can be a little easy but when you looking for circles of any size then you should read expert articles in this context. sorry but i don't think that anyone in this heaven can give you a perfect code of this. just google the "template matching" or "object recognition" to get some clues.

    sometimes 0 can be 1

    C# help

  • adapting a webcam driver to an existing form
    E erfi

    i can't download the code from your link. it has a problem. but here is some links which can help you: http://www.codeproject.com/KB/directx/PrgmngDirectShowappsCS.aspx[^] http://www.codeproject.com/KB/directx/directshownet.aspx[^] and the best resource for you is here : http://sourceforge.net/project/showfiles.php?group_id=136334[^] if you want to import codes from other projects to your project you shouldn't use their InitializeComponent() function. just add the necessary initialization codes after your InitializeComponent() function. like this :

    public Form1()
    {
    InitializeComponent();
    // add initialization codes here
    // ...
    }

    sometimes 0 can be 1

    modified on Wednesday, March 25, 2009 9:26 AM

    C# csharp question visual-studio com learning

  • Form refresh... and accept click on button while performing other task...
    E erfi

    yes. if your program works in a loop, the only whey to keep your UI alive is to use the Thread. write youre loop in a function and then run it on a thread.

    sometimes 0 can be 1

    Managed C++/CLI question help career

  • Circular Form Reference
    E erfi

    if you are creating a windows form application under CLR category then in Form1.h your code must be like this:

    #pragma once
    #include "Form2.h"

    namespace CircularForm {
    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;
    .
    .
    .

    private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
    Form2^ f2 = gcnew Form2();
    f2->Show();
    this->Close();
    }

    but when the form1 is closed the managed memory of form2 will be released. the whole program will be ended. there is 2 way to do this: 1. don't close the form1, just hide form1 and when form2 is closed show it(form1) again. 2. add a new class (Form3) containing two objects (Form1 f1, Form2 f2). set it as startup form and control the f1,f2

    sometimes 0 can be 1

    Managed C++/CLI

  • Form
    E erfi

    you should use an IntPtr variable in form2 to hold the Handle of form1 :

    public partial class Form1 : Form
    {
        Form2 form2;
    
        public Form1()
        {
            InitializeComponent();
            form2 = new Form2(this.Handle);        
        }
    
        private void button1\_Click(object sender, EventArgs e)
        {
            this.Hide();            
            form2.Show();            
        }
    }
    

    and

    public partial class Form2 : Form
    {
        private IntPtr friendHandle;
    
        public Form2(IntPtr hnd)
        {
            InitializeComponent();
    
            friendHandle = hnd;
        }
    
        private void button1\_Click(object sender, EventArgs e)
        {
            this.Hide();
            Form.FromHandle(friendHandle).Show();
        }
    }
    

    this works fine. i tried if you want to the information in the forms to be saved you souldn't make a new instance of forms in click event but if you don't need them then you are free to do it :laugh:

    sometimes 0 can be 1

    C# help question

  • How to make a setup of windows application
    E erfi

    there is a project type in visual studio : "New Project -> Other Project Types -> Setup and Deployment" i used it and made a setup for my application. it is very cool and has several options that makes your work very easy.

    sometimes 0 can be 1

    C# tutorial workspace

  • preventing being closed from task manager [modified]
    E erfi

    thank you Christian. that helped

    sometimes 0 can be 1

    C# question

  • preventing being closed from task manager [modified]
    E erfi

    i don't understand why some people read the messages just to give unrelated answers. this is a message board and someone asks a question and some people answer to it if the want to. so i f you don't know the answer or don't want to answer just don't do it. noone is going to judge you

    sometimes 0 can be 1

    C# question

  • preventing being closed from task manager [modified]
    E erfi

    there is no need for this option to write a malware. approximately 99% of malwares todays are attaches to windows processes and you can't find them in process list

    C# question

  • preventing being closed from task manager [modified]
    E erfi

    of course there must be a way to close the process but i want it to be from the program

    sometimes 0 can be 1

    C# question

  • preventing being closed from task manager [modified]
    E erfi

    i have a program that uses a process in background for some calculations. is there a way to prevent the process from being closed from task manager? just like antivirus programs that prevent their processes from being closed.

    sometimes 0 can be 1

    modified on Monday, February 9, 2009 4:23 PM

    C# question

  • Same Random Numbers
    E erfi

    you can change the seeds just use the overloaded random construction function like this :

    Random rand1 = new Random(1);
    Random rand2 = new Random(2);

    Console.WriteLine(rand1.Next(50));
    Console.WriteLine(rand2.Next(50));

    output is : 12 38

    sometimes 0 can be 1

    C# lounge

  • loop break on KeyDown [modified]
    E erfi

    please can someboby solve this problem for ever?! this is making me crazy. i googled but nothing was found. there is a "for loop" in my program and i want to break the loop on KeyDown event. my code is like this :

    private bool EXIT;
    private void Form1_KeyDown(object sender, KeyEventArgs e)
    {
    if (e.KeyCode == Keys.Escape)
    {
    EXIT = true;
    }
    }
    private void Function()
    {
    for (int x = 0; x < Max; x++)
    {
    if(EXIT)
    {
    break;
    }

         // work on image...
         OnPaintBackground(new PaintEventArgs(this.CreateGraphics(),new Rectangle(0,0,Width,eight)));
     }
    

    }
    protected override void OnPaintBackground(PaintEventArgs e)
    {
    e.Graphics.DrawImage( image, 0, 0, Width, Height);
    }

    when the Esc key is pressed nothing happens. what i have to do?

    sometimes 0 can be 1

    C# graphics help question

  • string table error
    E erfi

    i have a project from VC++ 6. i converted it to vc++.net 2005. when i rebuild the program an error appears : "string table error" i have the last version compiled and its work fine. do you have any idea why this error occurs?

    sometimes 0 can be 1

    C / C++ / MFC csharp c++ help question announcement

  • how to can i run or execute another program from C# ... like winword for example ??
    E erfi

    here is a simple application I wrote : there is a combobox on my form which lets user to select a program. in this case i just added 3 programs to it : (mediaplayer, freecell, MinesWeeper) also you can add the command line arguments to your process. by clicking the run button the fallowing code will run.

    private void runbtn_Click(object sender, System.EventArgs e)
    {
    Process myProcess = new Process();
    int selectedIndex = comboBox1.SelectedIndex;

        switch (selectedIndex)
        {
            case 0:
                myProcess.StartInfo.FileName = "C:/Program Files/Windows Media Player/wmplayer.exe";
                //myProcess.StartInfo.Arguments = "g:\\\\path\\\\filename.mp3";                
                break;
            case 1:
                myProcess.StartInfo.FileName = "c:/windows/system32/winmine.exe";
                break;
            case 2:
                myProcess.StartInfo.FileName = "c:/windows/system32/freecell.exe";
                break;
            default:
                myProcess.StartInfo.FileName = "C:/Program Files/Windows Media Player/wmplayer.exe";
                break;
        }
    myProcess.Start();
    

    }

    sometimes 0 can be 1

    modified on Sunday, June 15, 2008 10:26 AM

    C# tutorial csharp question

  • Including WPF Components
    E erfi

    ElementHost class is supported in .net faramework 3.5, 3.0 sp1, 3.0 here is the msdn link about this class : http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.elementhost.aspx[^]

    sometimes 0 can be 1

    C# csharp wpf question

  • problem with std::vector
    E erfi

    thanks i deleted the .ncb file and now it's working.

    C / C++ / MFC help c++ graphics question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups