Thread: Clipboard Threading Error

  1. #1
    Something Clever ginoitalo's Avatar
    Join Date
    Dec 2001
    Posts
    187

    Keys

    -How Would I Fix this error
    (Where & How do I mark the STAThreadAttribute )

    -This Occurs when I'm in a textbox (a large one) and execute a notepad-like cut or paste or copy

    Error:
    System.Threading.ThreadStateException: The current thread must set to Single Thread Apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it.

    What's the " Main Function ", the cut/copy/paste functions are like 3 lines long


    ideas ?
    Last edited by ginoitalo; 06-14-2002 at 06:33 PM.

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    There has to be a main function in your program. You need to mark this with the "STAThread"-Attribute.

    PHP Code:
    [STAThread]
    static 
    void Main() 
    {
         
    Application.Run(new frmMain());

    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Something Clever ginoitalo's Avatar
    Join Date
    Dec 2001
    Posts
    187
    Excellent !


    As a design idea, Would Using a Large "Docked" Textbox be the best way to create a quasi Notepad ?

    Also, Tabs Don't Work ?

    Comments Welcome...

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    A docked Textbox should be ok.

    Tabs work fine, what exactly is not working in your program ?
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  5. #5
    Something Clever ginoitalo's Avatar
    Join Date
    Dec 2001
    Posts
    187
    What I mean by tabs is that when your in the huge textbox and press tab, a tab doesn't appear like in notepad, the program tries to find the next TabStop.

    I'd like to implement a "Visual Studio like tab" where I can hilight several lines of text and tab them all together

  6. #6
    Something Clever ginoitalo's Avatar
    Join Date
    Dec 2001
    Posts
    187

    KEYS KEYS KEYS

    OK, you have to set the box to accept tabs.

    How do we test to see if SHIFT+TAB was pressed in :

    Code:
    protected void textBox1_TextChanged (object sender, System.EventArgs e){
    
          if ((Control.ModifierKeys | (Keys.Shift & Keys.Tab)) != ( Keys.Tab & Keys.Shift) ) {
    					MessageBox.Show("Pressed --> Shift + Tab");
          }
    
    }
    It Enters with Ctrl+z and SHIFT+Other Letters (not good)

    also,

    How can we check to see which key was pressed anytime in the Form ? arrow keys don't trigger in the TextChanged
    Last edited by ginoitalo; 06-13-2002 at 09:25 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  4. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  5. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM