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. Other Discussions
  3. The Weird and The Wonderful
  4. Visual Studio autogenerated code

Visual Studio autogenerated code

Scheduled Pinned Locked Moved The Weird and The Wonderful
visual-studiocsharp
20 Posts 11 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.
  • A adgonz

    This is the base code vs generates to check for special keys, on a Smart Device project:

        private void Form1\_KeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyCode == System.Windows.Forms.Keys.Up))
            {
                // Subir oscilador
                // Subir
            }
            if ((e.KeyCode == System.Windows.Forms.Keys.Down))
            {
                // Bajar oscilador
                // Bajar
            }
            if ((e.KeyCode == System.Windows.Forms.Keys.Left))
            {
                // Izquierda
            }
            if ((e.KeyCode == System.Windows.Forms.Keys.Right))
            {
                // Derecha
            }
            if ((e.KeyCode == System.Windows.Forms.Keys.Enter))
            {
                // Entrar
            }
    
        }
    

    A Pocket PC is full of power, so let's check for every possible key.

    0 Offline
    0 Offline
    0x3c0
    wrote on last edited by
    #6

    Ah, but this way there's a nice little hack brewing. Modify the parameters in some ASM code mid-execution, and you can invoke multiple segments of code. That way, there's two operating modes built in - cracker and normal user. Crackers can have super-special zero-bug privileges, while normal users can get walloped with the bug-hammer Of course, a nice little service running in the background on the target machines can do this automatically. Maybe a clause can be put in which stops modifying the code if certain packets are received. Grumpy, abusive user gets bugs, rich user with lots of contacts gets fewer

    1 Reply Last reply
    0
    • A adgonz

      This is the base code vs generates to check for special keys, on a Smart Device project:

          private void Form1\_KeyDown(object sender, KeyEventArgs e)
          {
              if ((e.KeyCode == System.Windows.Forms.Keys.Up))
              {
                  // Subir oscilador
                  // Subir
              }
              if ((e.KeyCode == System.Windows.Forms.Keys.Down))
              {
                  // Bajar oscilador
                  // Bajar
              }
              if ((e.KeyCode == System.Windows.Forms.Keys.Left))
              {
                  // Izquierda
              }
              if ((e.KeyCode == System.Windows.Forms.Keys.Right))
              {
                  // Derecha
              }
              if ((e.KeyCode == System.Windows.Forms.Keys.Enter))
              {
                  // Entrar
              }
      
          }
      

      A Pocket PC is full of power, so let's check for every possible key.

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #7

      You would delete the auto-generated code anyway wouldn't you? Actually isn't there a file (or files) that contain such things and you can change them there?

      A 1 Reply Last reply
      0
      • A adgonz

        This is the base code vs generates to check for special keys, on a Smart Device project:

            private void Form1\_KeyDown(object sender, KeyEventArgs e)
            {
                if ((e.KeyCode == System.Windows.Forms.Keys.Up))
                {
                    // Subir oscilador
                    // Subir
                }
                if ((e.KeyCode == System.Windows.Forms.Keys.Down))
                {
                    // Bajar oscilador
                    // Bajar
                }
                if ((e.KeyCode == System.Windows.Forms.Keys.Left))
                {
                    // Izquierda
                }
                if ((e.KeyCode == System.Windows.Forms.Keys.Right))
                {
                    // Derecha
                }
                if ((e.KeyCode == System.Windows.Forms.Keys.Enter))
                {
                    // Entrar
                }
        
            }
        

        A Pocket PC is full of power, so let's check for every possible key.

        M Offline
        M Offline
        Megidolaon
        wrote on last edited by
        #8

        This might not be a horror at all. Maybe it's intended this way (I don't know as I never used a Pocket PC). If the user presses multiple directions, several ifs are true and the code for each of them should be executed. Otherwise diagonal directions would be impossible because it would accept only a single directional key at once.

        A 1 Reply Last reply
        0
        • M Megidolaon

          This might not be a horror at all. Maybe it's intended this way (I don't know as I never used a Pocket PC). If the user presses multiple directions, several ifs are true and the code for each of them should be executed. Otherwise diagonal directions would be impossible because it would accept only a single directional key at once.

          A Offline
          A Offline
          adgonz
          wrote on last edited by
          #9

          Megidolaon wrote:

          If the user presses multiple directions

          Then multiple events are fired.

          M V 2 Replies Last reply
          0
          • P PIEBALDconsult

            You would delete the auto-generated code anyway wouldn't you? Actually isn't there a file (or files) that contain such things and you can change them there?

            A Offline
            A Offline
            adgonz
            wrote on last edited by
            #10

            PIEBALDconsult wrote:

            You would delete the auto-generated code anyway wouldn't you? Actually isn't there a file (or files) that contain such things and you can change them there?

            Of course, I can change the code, the same way you would change the code on all the horrors published here. Isn't this forum to publish horrors you find over there? I think this is a reply horror. :laugh:

            1 Reply Last reply
            0
            • A adgonz

              Megidolaon wrote:

              If the user presses multiple directions

              Then multiple events are fired.

              M Offline
              M Offline
              Megidolaon
              wrote on last edited by
              #11

              ...yes, thatwould be true

              P 1 Reply Last reply
              0
              • A adgonz

                It's not a big horror, its just funny to see it on Visual Studio. The correct implementation would be:

                    private void Form1\_KeyDown(object sender, KeyEventArgs e)
                    {
                        switch(e.KeyCode)
                        {
                            case System.Windows.Forms.Keys.Up:
                                // Subir oscilador
                                // Subir
                                break;
                                
                            case System.Windows.Forms.Keys.Down:
                                // Bajar oscilador
                                // Bajar
                                break;                
                                
                            case System.Windows.Forms.Keys.Left:
                                // Izquierda
                                break;                
                            
                            case System.Windows.Forms.Keys.Right:
                                // Derecha
                                break;                
                            
                            case System.Windows.Forms.Keys.Enter:
                                // Entrar
                                break;      
                                          
                         }
                        
                    }
                
                K Offline
                K Offline
                KarstenK
                wrote on last edited by
                #12

                it is a horror that this visible code is so poor. :mad: What about the non-visible code. Shame on Microsoft!!! X|

                Press F1 for help or google it. Greetings from Germany

                V 1 Reply Last reply
                0
                • M Megidolaon

                  ...yes, thatwould be true

                  P Offline
                  P Offline
                  Paulo Zemek
                  wrote on last edited by
                  #13

                  Even if multiple keys where able to be captured at the same time, using many == will not be a solution. After all, if the keys where combined using the | operator, as happens with flags, the right way to check the values will be using: if ((parameter & condition) == condition) or if ((parameter & condition) != 0) But that's not the case with keys. So, this is an ugly code (but not an horror in my opinion).

                  1 Reply Last reply
                  0
                  • K KarstenK

                    it is a horror that this visible code is so poor. :mad: What about the non-visible code. Shame on Microsoft!!! X|

                    Press F1 for help or google it. Greetings from Germany

                    V Offline
                    V Offline
                    VentsyV
                    wrote on last edited by
                    #14

                    Invisible code ?!?? Where ??

                    K 1 Reply Last reply
                    0
                    • V VentsyV

                      Invisible code ?!?? Where ??

                      K Offline
                      K Offline
                      KarstenK
                      wrote on last edited by
                      #15

                      I mean the code we cant look at, like the soruce code of windwos or Office. :-\

                      Press F1 for help or google it. Greetings from Germany

                      V 1 Reply Last reply
                      0
                      • S Stephen Hewitt

                        If the first if is true, for example, why bother testing all the others which follow? It's dopey code.

                        Steve

                        V Offline
                        V Offline
                        Vasudevan Deepak Kumar
                        wrote on last edited by
                        #16

                        That many bunch of ifs could have been elegantly presented with a decent switch block.

                        Vasudevan Deepak Kumar Personal Homepage
                        Tech Gossips
                        The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep!

                        1 Reply Last reply
                        0
                        • K KarstenK

                          I mean the code we cant look at, like the soruce code of windwos or Office. :-\

                          Press F1 for help or google it. Greetings from Germany

                          V Offline
                          V Offline
                          Vasudevan Deepak Kumar
                          wrote on last edited by
                          #17

                          KarstenK wrote:

                          we cant look at, like the soruce code of windwos or Office

                          But we can feel it and enjoy it with timely patches and service packs.

                          Vasudevan Deepak Kumar Personal Homepage
                          Tech Gossips
                          The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep!

                          K 1 Reply Last reply
                          0
                          • A adgonz

                            Megidolaon wrote:

                            If the user presses multiple directions

                            Then multiple events are fired.

                            V Offline
                            V Offline
                            Vasudevan Deepak Kumar
                            wrote on last edited by
                            #18

                            adgonz wrote:

                            multiple events are fired.

                            The application goes haywire and user runs amuck helter-skelter.

                            Vasudevan Deepak Kumar Personal Homepage
                            Tech Gossips
                            The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep!

                            1 Reply Last reply
                            0
                            • V Vasudevan Deepak Kumar

                              KarstenK wrote:

                              we cant look at, like the soruce code of windwos or Office

                              But we can feel it and enjoy it with timely patches and service packs.

                              Vasudevan Deepak Kumar Personal Homepage
                              Tech Gossips
                              The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep!

                              K Offline
                              K Offline
                              KarstenK
                              wrote on last edited by
                              #19

                              Now I am feeling the difference between Version "6.0" and "6.1 RC" of a wellknown Microsoft product. I feel that they really work hard and encouraged. :-O

                              Press F1 for help or google it. Greetings from Germany

                              1 Reply Last reply
                              0
                              • T Tony Pottier

                                I don't see any horror here. What do you want to do if you need to check for those keys?

                                S Offline
                                S Offline
                                sucram
                                wrote on last edited by
                                #20

                                Maybe he doesn't understand the Spanish. :laugh:

                                Vita est usquequaque virtus victus ut plenus. Ego non sum semper iustus tamen Ego sum nunquam nefas!

                                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