Display a hex value in a list box?

This is a discussion on Display a hex value in a list box? within the Windows Programming forums, part of the Platform Specific Boards category; Ok, so I've got a Dialog, with a listbox inside of it. I want to display a hex calue in ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    20

    Display a hex value in a list box?

    Ok, so I've got a Dialog, with a listbox inside of it. I want to display a hex calue in '0xFF' format, or even just 'FF'. I'm trying to use this list box as a crappy debug/log window for a program i'm working on.

    I'm currently using:

    Code:
    SendDlgItemMessage(hwnd,IDC_LIST1, LB_ADDSTRING,0,(LPARAM)Opcode);
    This obviously only displays the ascii value. Thanks!

  2. #2
    Madly in anger with you
    Join Date
    Nov 2005
    Posts
    211
    Code:
    char buf[10];
    
    wsprintf(buf, "%#X", Opcode);
    
    SendDlgItemMessage(hwnd,IDC_LIST1, LB_ADDSTRING,0,(LPARAM)buf);

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    20
    Quote Originally Posted by sl34k View Post
    Code:
    char buf[10];
    
    wsprintf(buf, "%#X", Opcode);
    
    SendDlgItemMessage(hwnd,IDC_LIST1, LB_ADDSTRING,0,(LPARAM)buf);
    Thanks, worked great. I don't think there is any way to do this in true cpp and not C, is there?

  4. #4
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by klipseracer View Post
    Thanks, worked great. I don't think there is any way to do this in true cpp and not C, is there?
    Sprintf/wsprintf is a part of the true C++. Everything doesn't have to be a class or an overloaded monster to be a part of the true C++...
    Last edited by maxorator; 01-27-2008 at 02:51 AM.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  5. #5
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,470
    it is possible to use stringstream I think
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  6. #6
    Registered User
    Join Date
    Jan 2008
    Posts
    20
    Quote Originally Posted by maxorator View Post
    Sprintf/wsprintf is a part of the true C++. Everything doesn't have to be a class or an overloaded monster to be a part of the true C++...
    well, thats good to know I suppose. I really just don't see any functions from the 'printf' derivation show up much without being in a .c source. I like printf a lot more anyhow for most things

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sorting linked list please help with CODE
    By scarlet00014 in forum C Programming
    Replies: 3
    Last Post: 09-27-2008, 11:24 PM
  2. Need help sorting a linked list. Beginner
    By scarlet00014 in forum C Programming
    Replies: 1
    Last Post: 09-27-2008, 06:16 PM
  3. instantiated from here: errors...
    By advocation in forum C++ Programming
    Replies: 5
    Last Post: 03-27-2005, 08:01 AM
  4. Replies: 6
    Last Post: 03-02-2005, 01:45 AM
  5. List class
    By SilasP in forum C++ Programming
    Replies: 0
    Last Post: 02-10-2002, 04:20 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21