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
  1. Home
  2. General Programming
  3. C#
  4. trouble with Form.Activate(); FormSelect(); Form.BringToFront();

trouble with Form.Activate(); FormSelect(); Form.BringToFront();

Scheduled Pinned Locked Moved C#
helpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    spiritboy
    wrote on last edited by
    #1

    hi , I created a fullscreen form, setting its topmost prperty to true and provide 2 textboxes in it (for username and password) so i create a lock screen program usin this way. i use a Timer that ticks every 500msec: it causes the form stays on top even if user press ALT-CNTRL-DLT

    void aTimer_Tick(object sender, EventArgs e )
    {

            try
            {
                this.Activate();
                this.Select();
                this.BringToFront();
            }
            catch 
            {
                
            }
            
        }
    

    then i put the address of my program as a startup program, and it will run each time i login but the problem is when i log in!! if i quicly run a program(beform my (Lock)form open) then i can hack the lock screen and it won't come to top,unless i click it! it seems that this.Activate(); this.Select(); this.BringToFront(); doesn't work when first the form is not active! any suggestions?

    1 S 2 Replies Last reply
    0
    • S spiritboy

      hi , I created a fullscreen form, setting its topmost prperty to true and provide 2 textboxes in it (for username and password) so i create a lock screen program usin this way. i use a Timer that ticks every 500msec: it causes the form stays on top even if user press ALT-CNTRL-DLT

      void aTimer_Tick(object sender, EventArgs e )
      {

              try
              {
                  this.Activate();
                  this.Select();
                  this.BringToFront();
              }
              catch 
              {
                  
              }
              
          }
      

      then i put the address of my program as a startup program, and it will run each time i login but the problem is when i log in!! if i quicly run a program(beform my (Lock)form open) then i can hack the lock screen and it won't come to top,unless i click it! it seems that this.Activate(); this.Select(); this.BringToFront(); doesn't work when first the form is not active! any suggestions?

      1 Offline
      1 Offline
      12Code
      wrote on last edited by
      #2

      Set the lock screen always on top.

      ;)*12Code

      S 1 Reply Last reply
      0
      • 1 12Code

        Set the lock screen always on top.

        ;)*12Code

        S Offline
        S Offline
        spiritboy
        wrote on last edited by
        #3

        Always on top? is it a property? i think it is TopMost property that i have set to true!

        H 1 Reply Last reply
        0
        • S spiritboy

          Always on top? is it a property? i think it is TopMost property that i have set to true!

          H Offline
          H Offline
          Henry Minute
          wrote on last edited by
          #4

          Take a look at the SetWindowPos API call. You might also Google 'make form always on top c#'. There are loads of 'solutions' to this problem, some of them might do what you want.

          Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

          1 Reply Last reply
          0
          • S spiritboy

            hi , I created a fullscreen form, setting its topmost prperty to true and provide 2 textboxes in it (for username and password) so i create a lock screen program usin this way. i use a Timer that ticks every 500msec: it causes the form stays on top even if user press ALT-CNTRL-DLT

            void aTimer_Tick(object sender, EventArgs e )
            {

                    try
                    {
                        this.Activate();
                        this.Select();
                        this.BringToFront();
                    }
                    catch 
                    {
                        
                    }
                    
                }
            

            then i put the address of my program as a startup program, and it will run each time i login but the problem is when i log in!! if i quicly run a program(beform my (Lock)form open) then i can hack the lock screen and it won't come to top,unless i click it! it seems that this.Activate(); this.Select(); this.BringToFront(); doesn't work when first the form is not active! any suggestions?

            S Offline
            S Offline
            spiritboy
            wrote on last edited by
            #5

            SetForegroundWindow: makes the specified window the current foreground window and gives it the focus. This function should only be used with windows which your program owns. Of course this function should be used with caution, since the user usually doesn't expect the foreground window to change unexpectedly. The function tells Windows to somehow draw the user's attention to the window, such as by flashing its icon in the taskbar. The function returns 1 if successful, or 0 if an error occured. maybe i should disable the feature of flashing in taskbar?

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

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