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
L

likefood

@likefood
About
Posts
135
Topics
39
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • I thought I couldn't shadow...
    L likefood

    It appears that C# does not allow shadowing from within a decision block. It has already been clarified that it won't work between inside and if-block and its outer method. And I already knew you can't shadow between case statements in a switch block (when you can with Java). However, it has no problem with it between a method and its class (or between an inner and an outer class). It would be cool if that distinction was made more clear in the documentation. Thanks for pointing out the decision-block scenario to me, StephenWhitfield and Navaneeth!

    -Daniel Typing too fast fro my owngood

    C# csharp c++ testing beta-testing tutorial

  • I thought I couldn't shadow...
    L likefood

    Even though that DOES compile in C++, it's not quite what I was expecting. From different sites (google "variable shadowing"), variable shadowing always refers to when a variable shares its name with that of a different class, method, or struct, not if-block scope. I agree that if-block scope is still just another level of scope (deeper than method or class scope), but it's not specified in different definitions of variable shadowing (only class/struct and method scopes are mentioned, not if-blocks). Thank you for bringing that to my attention, I hadn't though of if-blocks. We'll see how long it lasts if I add that detail to the Wikipedia article...

    -Daniel Typing too fast fro my owngood

    C# csharp c++ testing beta-testing tutorial

  • I thought I couldn't shadow...
    L likefood

    I was reading in Wikipedia (don't say it) about how C# is one of the languages in which you can't use variable shadowing. The article gives an example of shadowing in C++ (in which you CAN shadow variables). However, I have been unaware of this limitation (and I think I may have used variable shadowing in the past). Just to be sure, I typed up a similar bit of code in C#, and it compiled and ran just fine:

    using System;
    public class test
    {
    public static int testing = 0;

    public static void Main()
    {
    	int testing = 1;
    	Console.WriteLine(testing);
    	Console.WriteLine(test.testing);
    	Console.ReadLine();
    }
    

    }
    // console output is:
    // 1
    // 0

    So, how is it NOT variable shadowing, if it's the same construction as the C++ example? Is it just that they renamed it something else (like "hiding")?

    -Daniel Typing too fast fro my owngood

    C# csharp c++ testing beta-testing tutorial

  • switch off computer
    L likefood

    Thank you, Xmen, but the PowerOff and ForcedPowerOff enum values are deceptive. Yes, they do power off the computer, but they also shut down Windows before then. I was looking for a way to power off the computer without wasting time shutting down Windows (the computer just goes silent right after I double-click something.exe on my desktop). But, thanks anyway!

    -Daniel Typing too fast fro my owngood

    C# tutorial question

  • switch off computer
    L likefood

    I guess I have some reading to do... http://msdn.microsoft.com/en-us/library/cc268228.aspx Thank you for pointing me toward System.Managment, all!

    -Daniel Typing too fast fro my owngood

    C# tutorial question

  • switch off computer
    L likefood

    Looking up WMI, it appears that the following should work like I want:

    ManagementClass mc = new ManagementClass("CIM_PowerSupply");
    object[] methodArgs = { 6, null };//with 6 being to power off
    object result = mc.InvokeMethod("SetPowerState", methodArgs);

    However, the program crashes with a ManagementException, saying "This method is not implemented in any class." And, Microsoft's article on the SetPowerState function says "This method is currently not implemented by WMI. To use this method, you must implement it in your own provider." It's kind of cruel to tease me with a function that doesn't actually do anything... Anyone know how it's supposed to be "implemented"?

    -Daniel Typing too fast fro my owngood

    C# tutorial question

  • switch off computer
    L likefood

    I'll look into this one, too, thank you!

    -Daniel Typing too fast fro my owngood

    C# tutorial question

  • switch off computer
    L likefood

    shutdown.exe would shut down Windows and then turn off the machine (depending on the arguments). However, I wish to bypass the "shut down Windows" part and just turn off the machine from the program. Yes, I know, it's not healthy. But I have a need regardless.

    -Daniel Typing too fast fro my owngood

    C# tutorial question

  • switch off computer
    L likefood

    I'll look into this one, thank you!

    -Daniel Typing too fast fro my owngood

    C# tutorial question

  • switch off computer
    L likefood

    I did a search to see if this has already been answered, but didn't find anything (if it's already been answered, please just point me in the right direction). I need to find out how to switch off the computer at runtime, meaning from a program, not by pushing the button on the tower :) . I suppose I could just create a process using shutdown.exe with args, but that actually shuts down Windows, and I want to bypass that. I have seen it done in the past (but I don't remember what program did it). I'm hoping there's some unmanaged function call (to some dll somewhere) that will simply power off the machine with no dialogs or anything. Just beeooooop, the machine is off. Anyone?

    -Daniel Typing too fast fro my owngood

    C# tutorial question

  • quick newline question for a noob
    L likefood

    Nevermind, I found it myself. I'm using an OdbcCommand object with an OdbcParameter.

    -Daniel Typing too fast fro my owngood

    Database database question csharp help tutorial

  • quick newline question for a noob
    L likefood

    Basically, I need to find out how to put multiple lines of text into a memo field. The text may or may not have apostrophes, quotes, backslashes, and other characters that usually require special treatment in other circumstances. Anyone?

    -Daniel Typing too fast fro my owngood

    Database database question csharp help tutorial

  • quick newline question for a noob
    L likefood

    I'm starting out with database programming in C# (using System.Data.Odbc). I have an SQL command, using the UPDATE command. I'm trying to update a memo field (in an .mdb file) with contents that have multiple lines of text. However, I keep getting an error. I can see what the error is saying (that it doesn't like me starting a line without an SQL command). How do I modify the following example so that it will work? UPDATE mytable SET pagecontents = 'first line of text second line of text third line of text' WHERE id = 3 The error basically says: ERROR [42000] [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression "second line of text thirdline of text'

    -Daniel Typing too fast fro my owngood

    Database database question csharp help tutorial

  • notification of change
    L likefood

    I need to find out how to make it so that my program is notified whenever the user's wallpaper is changed. How do I get Windows to tell me that? (I really don't like the idea of setting a timer to check the registry every few seconds)

    -Daniel Typing too fast fro my owngood

    C# question windows-admin tutorial

  • user's current wallpaper
    L likefood

    I only needed to get the wallpaper. I didn't know that the registry's value was updated that well (I just looked on mine and it's correct, despite me circumventing the control panel applet), so I'm good to go. I already know how to set the wallpaper (and I have a handy app available for free download from my blog). Thank you for the info! It helps me greatly!

    -Daniel Typing too fast fro my owngood

    C# question graphics json

  • user's current wallpaper
    L likefood

    How do I get the user's current wallpaper bitmap? (keeping in mind that the user might have set the wallpaper with either the desktop properties control panel applet, or with the SetParametersInfo method in user32.dll) Is there an API call that returns a bitmap or a handle that I can use to create a Bitmap object? I'm not wanting to change or alter the wallpaper, I'm wanting to display it as a Bitmap object on a Form.

    -Daniel Typing too fast fro my owngood

    C# question graphics json

  • resend mouse messages
    L likefood

    I understand that I can't alter how another window paints itself. That's why I needed a click-through-able window. Your shameless plug is exactly what I needed! (well... after manually converting the VB to C#) However, it wasn't working exactly 100%. I took out the lines that changed [myform].Opacity and it seems to be working just fine now (using SetLayeredWindowAttributes instead of Form.Opacity). Thank you! I now have a wallpaper that seems to "show through" all of my windows (as if all of my windows were semitransparent)!

    -Daniel Typing too fast fro my owngood

    C# question tutorial

  • resend mouse messages
    L likefood

    I have a program that is semitransparent and is topmost. If a different program has focus, the keyboard messages reach it (the other program) just fine, but my topmost form intercepts mouse input (understandably so). How can I make my program take all mouse input and resend it through Windows's message pool so that it's as if my program wasn't there? I want to be able to function in the other active applications as if my program wasn't there (wasn't topmost). The reason it has to be topmost is because it has a duplicate of the user's background image on it. Being semitransparent, it gives the effect that, instead, all of the other programs are semitransparent (the ultimate goal), so that the user can still faintly see their wallpaper "behind" their programs (because I don't know how to forcefully reduce all other programs' opacity).

    -Daniel Typing too fast fro my owngood

    C# question tutorial

  • new to asp.net
    L likefood

    When I use VisualStudio, I add a class to the website project. It adds a cs file to an App_Code folder (or something similar). You think I should use a webservice instead? I'll look into it. Thanks for the info! Basically, the client app should pass a string to the server, and the server should process it and return another string. That's basically it (and I don't know how to do it). The whole thing about an aspx file and a cs file is from what I was able to figure out by myself. If there's a better way, I'm more than willing to give it a try.

    -Daniel Typing too fast fro my owngood

    ASP.NET csharp asp-net sysadmin question

  • new to asp.net
    L likefood

    I'm just starting to get into ASP.net, so forgive my noob-ness. Normally, I use straight C# for client apps. I have a little project I'm trying to start, but things aren't working right (even with VisualStudio). What I want to do is this: - a client C# app sends a string to an aspx page - the aspx page sends the string to a server-side C# file - the server-side cs file processes the string and sends back a string to the aspx file - the aspx file sends the processed string to the client C# app I have to have the server-side C# file because it won't let me use some Windows.Forms objects in just an aspx file. Where do I start at accomplishing this?

    -Daniel Typing too fast fro my owngood

    ASP.NET csharp asp-net sysadmin 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