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
T

Taka Muraoka

@Taka Muraoka
About
Posts
2.3k
Topics
222
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Using IAuthenticate with an MSHTML control
    T Taka Muraoka

    I've got MSHTML calling my IAuthenticate interface to get the username/password when it's downloading stuff that needs authentication, but how do I know if it worked? I have a username/password that will be correct *most* of the time but if it's not, I want to disable calls to my IAuthenticate so that the browser will revert to its normal behaviour i.e. show a dialog asking for authentication details. It'd be nice if I could also instruct the MSHTML instance to retry without using the credentials I supplied. But to do any of this, I need to know if the username/password I gave worked. Just checking for a HTTP 401/3 might not work since I sometimes seem to get a "This page cannot be displayed" error.


    I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be [^]. Awasu 2.4 [^]: A free RSS/Atom feed reader with support for Code Project.

    COM question com security help

  • Help authoring
    T Taka Muraoka

    I use FAR[^] for Awasu. Not too expensive and it gets the job done. You use a normal HTML editor to actually write the pages and then FAR to compile the help file.


    I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be [^]. Awasu 2.3.3 [^]: A free RSS/Atom feed reader with support for Code Project.

    The Lounge com help question

  • Any way to refresh a CHtmlView without it scrolling back to the top?
    T Taka Muraoka

    The only thing that's changed is a few small icons scattered throughout the page so it's kinda annoying that calling Refresh() loses the current scroll position. Tried saving and restoring the scroll position used the techniques described here[^] (and in the comments) but despite no failure codes returned, the page doesn't want to scroll :-(


    I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be [^]. Awasu 2.3.3 [^]: A free RSS/Atom feed reader with support for Code Project.

    C / C++ / MFC com question

  • What's the point of IEnumerable and IEnumerable<T>?
    T Taka Muraoka

    Scott Dorman wrote:

    Defining the member in an interface doesn't imply that it is virtual at all.

    Aha! This is the root of my confusion. I was assuming that a C# interface was the same as a C++ interface (i.e. a collection of pure virtual/abstract methods). I remembered reading in the O'Reilly "C# Essentials" book that a C# interface was simply a syntactic shortcut for a bunch of abstract members in an abstract class but their exact wording was "similar to" :| The output from the following code gave me a surprise:

    interface I
    {
    void foo( string msg ) ;
    }

    class A : I
    {
    public void foo( string msg ) { System.Console.WriteLine( msg+" -> A::foo" ) ; }
    }

    class B : A
    {
    public void foo( string msg ) { System.Console.WriteLine( msg+" -> B::foo" ) ; }
    }

    static void Main()
    {
    B b = new B() ;
    ((I)b).foo( "Static type I" ) ;
    ((A)b).foo( "Static type A" ) ;
    ((B)b).foo( "Static type B" ) ;
    }

    --- OUTPUT ---
    Static type I -> A::foo
    Static type A -> A::foo
    Static type B -> B::foo

    In C++, the B::foo() method would've been called every time. No wonder I thought foreach appeared to be ignoring the IEnumerable's in the inheritance hierarchy. In every other OO language I've worked with, to get access to GetEnumerator() you would have to go through the IEnumerable but in C#, deriving from an interface seems to be little more than a directive to the compiler telling it that certain methods need to defined i.e. it doesn't really affect the class as such (e.g. by causing the layout of the v-table to change, or whatever C# uses). Playing around a little with the definition of B:

    class B : A,I
    {
    void foo( string msg ) { System.Console.WriteLine( msg+" -> B::foo" ) ; }
    }

    --- OUTPUT ---
    Static type I -> A::foo
    Static type A -> A::foo
    Static type B -> A::foo

    That's weird, but I think because B::foo() is not public:

    class B : A,I
    {
    public void foo( string msg ) { System.Console.WriteLine( msg+" -> B::foo" ) ; }
    }

    --- OUTPUT ---
    Static type I -> B::foo
    Static type A -> A::foo
    Static type B -> B::foo

    And how about these two:

    class B : A,I
    {
    void foo( string msg ) { System.Console.WriteLine( msg+" -> B::foo" ) ; }
    void I.foo( string msg ) { System.Console.WriteLine( msg+" -> B::foo 2" ) ; }
    }

    --- OUTPUT ---
    Static type I -> B::foo 2
    Static type A -> A::foo
    Static type B -> A::foo

    c

    C# question csharp java visual-studio com

  • What's the point of IEnumerable and IEnumerable<T>?
    T Taka Muraoka

    Scott Dorman wrote:

    By deriving X from IEnumerable you are effectively telling the type system that when you enumerate over X (by calling GetEnumerator) that you are returning a type of int not X. Isn't that the point of providing the strongly typed version? You (and the compiler) know at compile time what the data type will be, so there is no need for it to call the non-typed version.

    That's right, this is the behaviour I want but I was playing with the code you gave because I wanted to get a better handle on what was really going on. I was wondering if the non-generic GetEnumerator() would get called if I tried to iterate using something other than int's. But see my next comment...

    Scott Dorman wrote:

    If you derive from an interface you have to implement all of the methods defined in the contract.

    Maybe the problem is because I'm still thinking in C++. If I write a C++ class that derives from an interface that in turn derives from another interface, my class has to effectively implement two interfaces. This is reinforced by the fact that I have to implement both versions of GetEnumerator(). So it seems to me that I should be able to foreach over an X using int's (via the generic interface) or using object's (via the non-generic interface). But it seems the compiler is unable to infer which one to call and onlys allow access to the generic one, giving a compile error if you try to "use" the non-generic one. Are there rules governing this i.e. why not the other way around?

    Scott Dorman wrote:

    The key is which method is defined explicitly or implicitly.

    Maybe this is the problem, I don't quite understand what the difference is. No such thing exists in C++ - if a method is pure virtual, you have to implement it, end of story. The fact that your 2b code works really makes me think foreach is ignoring the interface hierarchy and just looks for a public GetEnumerator() method. But on the other hand, the generic GetEnumerator() definition in 2b must be equivalent to the one in 2a (i.e. 2 different ways of defining the same thing, otherwise the compiler would be complaining about an un-implemented interface method) but so then, why does declaring it public make a difference?!

    Scott Dorman wrote:

    When you declare one of them as public you are telling the compiler that this i

    C# question csharp java visual-studio com

  • What's the point of IEnumerable and IEnumerable<T>?
    T Taka Muraoka

    Scott Dorman wrote:

    1: Leave your class X defined as is, and change the call in the foreach loop to read

    foreach (int n in (IEnumerable<int>x)
    {
    System.Console.WriteLine(n);
    }

    This is obviously kinda ugly. The intent of deriving from IEnumerable<T> is to enforce type-safety and I was hoping that the compiler would be smart enough to realize that X can only be iterated over using int's and nothing else.

    Scott Dorman wrote:

    2: Leave the foreach call as is, and change X to read:

    Both these work but there are still some oddities. The following code compiles but throws a cast exception at runtime, which is what one (or at least I) would expect:

    class X
    {
    private List<int> mList = new List<int>() ;
    public X() { mList.Add(1) ; mList.Add(2) ; mList.Add(3) ; }
    public IEnumerator GetEnumerator() { return mList.GetEnumerator() ; }
    }

    foreach ( X n in x ) // nb: iterate using an X, not an int
    System.Console.WriteLine( n ) ;

    But using the modified foreach with either of your #2 code samples doesn't even compile ("Cannot convert int to X"). So it seems that there's now no way to get into the non-generic GetEnumerator() :rolleyes: I don't particularly want to but it annoys me that I have to define this method but it never gets used :-) So, it looks like foreach is ignoring whether the object it's iterating over derives from IEnumerable or IEnumerable<T> and just looks for a public GetEnumerator() method (which is kinda lame). But then how does it know which GetEnumerator() to use in your 2a code? Both of them are public in their respective interfaces, and yes, I tried reversing the order they are defined in :-) I was kinda hoping the compiler could infer which one to use by the type being used in the foreach statement but for some reason, it's only allowing the generic one to be used. Oh well, I guess we can just chalk this one up to C# evolving on the fly. Thanks for your help.


    I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be [^]. Awasu 2.3.2 [^]: A free RSS/Ato

    C# question csharp java visual-studio com

  • What's the point of IEnumerable and IEnumerable&lt;T&gt;?
    T Taka Muraoka

    Scott Dorman wrote:

    I think what you will find behind the scenes in the IL is pretty much the same calls if you used a class that implemented IEnumerable or one that didn't. The code generated is still a call to GetEnumerator and then calls to GetCurrent.

    I haven't really bothered looking too deeply into IL but as a hard-core C++ guy, it certainly doesn't make any sense.

    Scott Dorman wrote:

    The fact that foreach works without IEnumerable was probably done in order to provide the most flexibility. I wouldn't necessary say that it suggests "someone who doesn't really know what they are doing".

    Well, it doesn't really make any sense from a general OO point of view, either :-)

    Scott Dorman wrote:

    What are you using to determine that the generic GetEnumerator isn't being called?

    Just stepping through in the debugger. Modifying it in the code sample in my OP to return null seems to have no ill effects.


    I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be [^]. Awasu 2.3.2 [^]: A free RSS/Atom feed reader with support for Code Project.

    C# question csharp java visual-studio com

  • What's the point of IEnumerable and IEnumerable&lt;T&gt;?
    T Taka Muraoka

    Thanks for the info.

    Scott Dorman wrote:

    The fact that C# implements a foreach iterator was done mostly as a convenience for the developer more than anything else.

    Given that this kind of feature is pretty standard in modern languages, I'd say it's perhaps a little more than a developers' convenience. But it wouldn't even occur to me to do it any other way than via the IEnumerable interface. For someone to say "we'll have it accept anything that has a GetEnumerator() method" suggests to me someone who doesn't really know what they're doing :|

    Scott Dorman wrote:

    The rules for implementing the generic IEnumerable exist that way because IEnumerable implements the IEnumerable interface.

    This is the one that really baffles me. The generic GetEnumerator() doesn't appear to get called so I don't quite see the point of having IEnumerable<T> at all. You might as well just derive from IEnumerable :shrug:


    I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be [^]. Awasu 2.3.2 [^]: A free RSS/Atom feed reader with support for Code Project.

    C# question csharp java visual-studio com

  • What's the point of IEnumerable and IEnumerable&lt;T&gt;?
    T Taka Muraoka

    So, I found out by accident that a class doesn't actually need to implement IEnumerable to be able to foreach over it. This works just fine (VS2005):

    class X
    {
    private List<int> mList = new List<int>() ;
    public X() { mList.Add(1) ; mList.Add(2) ; mList.Add(3) ; }
    public IEnumerator GetEnumerator() { return mList.GetEnumerator() ; }
    }

    X x = new X() ;
    foreach ( int n in x )
    System.Console.WriteLine( n ) ;

    MSDN confirms[^] this behaviour:

    Evaluates to a type that implements IEnumerable or a type that declares a GetEnumerator method.

    Although this[^] suggests that it's a C# thing only.

    The reason for implementing IEnumurable therefore, is (a) to identify the class as enumerable/foreach-able, and (b) to provide a language independant implementation that will work in other languages that don't provide the C# foreach performance "hack".

    But even given that, it still begs the question: why did the C# team feel the need for foreach to accept objects that don't implement IEnumerable? But it gets worse when using generics. Deriving X from IEnumerable<T> forces you to implement both the generic (expected) and non-generic (huh?!) version of GetEnumerator():

    class X : IEnumerable<int>
    {
    private List<int> mList = new List<int>() ;
    public X() { mList.Add(1) ; mList.Add(2) ; mList.Add(3) ; }
    IEnumerator<int> IEnumerable<int>.GetEnumerator() { return mList.GetEnumerator() ; }
    public IEnumerator GetEnumerator() { return mList.GetEnumerator() ; }
    }

    X x = new X() ;
    foreach ( int n in x )
    System.Console.WriteLine( n ) ;

    Except that when stepping through the debugger, foreach uses the *non-generic* GetEnumerator(). So why even bother having the generic one? I'm pretty new to C# but this seems kinda dumb. Am I missing something?


    I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be [

    C# question csharp java visual-studio com

  • Intellisense
    T Taka Muraoka

    Justin Perez wrote:

    We want to do IntelliSense with a RichTextBox, and have the objects that would pop up be stored in an XML file.

    BCGSoft have an advanced edit control[^] that does all that kind of stuff. Haven't really used it much myself but I've been pretty happy with the rest of their library.

    The Lounge question visual-studio xml help announcement

  • Is it April 1?
    T Taka Muraoka

    peterchen wrote:

    "Demonstrated ability to work effectively with executives. Strong executive presence and maturity."

    Yes, I noticed that as well but just took it to mean "good ass-kisser" :|


    I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be [^]. Awasu 2.3.1 [^]: A free RSS/Atom feed reader with support for Code Project. 50% discount on the paid editions for CP memb

    The Lounge question html com tools help

  • which is the BEST love vs Friendship
    T Taka Muraoka

    Marc Clifton wrote:

    She'll be impressed with your newfound capabilities for intelligent discussion.

    :wtf: You were the inspiration for this one, right? :laugh:


    I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be [^]. Awasu 2.3.1 [^]: A free RSS/Atom feed reader with support for Code Project. 50% discount on the paid editions for CP memb

    The Lounge visual-studio question

  • IT Technician Call Center
    T Taka Muraoka

    Christian Graus wrote:

    Judging from my experiences with tech support, if you can say 'is the firewall turned off', 'is it plugged in' and 'is it turned on', you will be fine.

    That's pretty much right. I'm the Philippines now and I met one girl at the pub the other night who told me her job was training people to provide IT support. It didn't take me long to ascertain that she knew *absolutely nothing* about computers and that she was actually training them how to read a script. I just poured myself another really big shot of rum... :doh:


    I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be [^]. Awasu 2.3.1 [^]: A free RSS/Atom feed reader with support for Code Project. 50% discount on the paid editions for CP members!

    The Lounge question career help lounge

  • Do you believe in ghosts?
    T Taka Muraoka

    JimmyRopes wrote:

    My favorite "holiday" (non Buddhist) is when we gather once a year as a family and each person speaks a testament to a dearly departed ancestor and then with much fanfare we all drink a toast to that person.

    I've never heard of this one! What's it called? BTW, sounds like you're back in the LOS?


    I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be [^]. Awasu 2.3 [^]: A free RSS/Atom feed reader with support for Code Project. 50% discount on the paid editions for CP members!

    The Lounge question

  • Ecard / postcard spam - actually it does have a useful purpose
    T Taka Muraoka

    John Cardinal wrote:

    I'm wondering now if those ecard companies who are legit know how badly they are going to get hammered by this spam as people increasingly filter out anything ecard related.

    I'm sure it's not a problem. This[^] is apparently the recommendation from the Greeting Card Association:

    _If you are unsure if an e-card notice is genuine, we strongly recommend that you go directly to the publisher’s website to safely retrieve your e-card. To do this:

    • Manually type the name of the card publisher’s website URL into your browser window.
    • Locate the “e-card pick up” area on the publisher’s website.
    • Take the card number or retrieval code information contained in the E-mail and enter it into the appropriate box or boxes on the publisher’s e-card pick-up area.

    _

    :doh:


    I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be [^]. Awasu 2.3 [^]: A free RSS/Atom feed reader with support for Code Project. 50% discount on the paid editions for CP members!

    The Lounge

  • Satips- I-am :)
    T Taka Muraoka

    JimmyRopes wrote:

    This is an unnecessarily vindictive affront to Santips. Santips is trying to reform his behavior to be more acceptable in the lounge. Let your hatred rest.

    Mate, there's no point trying to reason with a mob :rolleyes:


    I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be [^]. Awasu 2.3 [^]: A free RSS/Atom feed reader with support for Code Project. 50% discount on the paid editions for CP members!

    The Lounge csharp wcf com data-structures xml

  • A classless society
    T Taka Muraoka

    Marc Clifton wrote:

    I actually find it odd that I'm arguing in favor of an automated classification system

    :-D Actually, so did I :rolleyes:

    Marc Clifton wrote:

    perused the high rated articles to start getting ideas of what a good article is for the people here.

    This is perhaps a little different (although not much). A high rating for an article means that the article's probably a bit better than average but since there's nothing stopping people from creating accounts and voting for their own articles, you can only put so much weight on it. But I find it useful as a starting point when I'm faced with a large number of articles to sift through. You can usually tell pretty quickly once you start reading whether it's any good or not :-)

    Marc Clifton wrote:

    I wanted to get that platinum membership

    You hit the nail on the head: people care about rankings and titles and awards. I'm probably unusual in that I (generally) don't.


    I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be [^]. Awasu 2.3 [^]: A free RSS/Atom feed reader with support for Code Project. 50% discount on the paid editions for CP members!

    The Lounge css com agentic-ai question discussion

  • A classless society
    T Taka Muraoka

    Marc Clifton wrote:

    Differences are facts. "better" or "worse" are values assigned to those differences.

    I don't quite see what your point is. The only reason we have class systems is so that one set of people can call themselves better than others :rolleyes: Sure, people are different from each other and if you want to group them according to those differences, I guess that'd be a *classification* system. But a *class* system is based purely on the perceived value of each class. It's inherently a value-based system.

    Marc Clifton wrote:

    The problem with an Internet society is that it's much more difficult to recognize the differences in people because they're more anonymous, which makes classification of people more important.

    Completely disagree :-) The importance is no different to that in real life. Yes, it's harder, so that means you need to be more perceptive, have a different set of tools for assessing people and it takes longer. But the only classification of people that has any value to me is the one that I make myself, based on my opinion of them, which will be formed by my observing their behaviour over a period of time. I will certainly take into account the thoughts of other people who's opinions I respect and value but the idea that I would give a rat's ass about something as trivial as post count or votes is just silly.

    Marc Clifton wrote:

    If all class distinctions are removed, then there's no way for a person, without hanging out at CP every day for a few months, to determine who is a high-value contributor. All that does is shove the classification-value system onto each person rather than having some "rules" for automatically creating a value-class system.

    Bingo! This is *exactly* the point I'm making. Judging value is hard. It can't be done off-the-cuff or via an automated system, it can't be distilled down into a single number or rank. It's exactly the same problem we see in schools: it's really difficult to know whether a student knows the material, is intelligent, so we put in place all this crap to enable us to make quick decisions about people. We reduce years of work down into a single grade, or even worse, a binary HAS/DOES NOT HAVE degree :doh: If you were away from CP for a few months and saw a bunch of new people when you came back, would you form opinions of them based on their post content, th

    The Lounge css com agentic-ai question discussion

  • A classless society
    T Taka Muraoka

    Marc Clifton wrote:

    The problem is not the class system, but the value people assign to different classes.

    Was this post supposed to be satirical and people didn't get it? What is a class system *other* than the value people assign the different classes? You say that the point of a class system is to recognize that people are different from others. I disagree; the point of a class system is to recognize that some people are (supposedly) *better* than others. Simply by removing CP's classification system doesn't mean that we will suddenly become indistinguishable from one another. The differences between people won't suddenly vanish, it's just a question of how they will be recognized. Some people will still be recognized as high-value contributors and others less so, but it will be done on merit and community opinion rather than via some automated system that can be gamed. Honestly, how lame is it to think that a special status on an internet forum (especially one based on something as simplistic as your post count or votes) has any kind of value whatsoever. I'll take the respect of my peers, even if it's completely unpublicized and anonymous, over that any day.


    I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be [^]. Awasu 2.3 [^]: A free RSS/Atom feed reader with support for Code Project. 50% discount on the paid editions for CP members!

    The Lounge css com agentic-ai question discussion

  • Offshore rates...
    T Taka Muraoka

    Patrick Sears wrote:

    the bottom line shouldn't be all that matters to a socially responsible corporation.

    I actually agree with you :-) I think offshoring is a bad move in the long term. The work coming back may not be of the highest quality right now but if there's one thing these guys are, they're hungry, and they learn fast. We're basically training them up to take over our IT sector :doh: As you said, management don't consider the long term because they don't get any credit for doing so. And in the same way one can hardly blame the offshore workers for doing what they do, one can also have some (a very small amount) of sympathy for the situation managers are in. If you or I were in their shoes, would we risk our multi-million dollar bonuses and our job for some nebulous future benefits? The markets would take one look at what we were doing and give a collective and giant WTF?!, and we'd be out on our ear. But it bugs me when people frame this as a issue of nationalism, "it's un-American, Americans are losing jobs." Be against it because yes, it'd be digging our own graves, but nationalism is something I never really got. What if a New York company outsourced some of their work to Des Moines because it was cheaper, would we see the same kind of backlash? Or even Canada? But go the other way and send the work to Mexico and I'm sure you'd see a much different reaction :rolleyes:


    I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be [^]. Awasu 2.3 [^]: A free RSS/Atom feed reader with support for Code Project. 50% discount on the paid editions for CP members!

    The Lounge csharp com architecture tutorial
  • Login

  • Don't have an account? Register

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