User Profile

Collapse

Profile Sidebar

Collapse
DelphiCoder
DelphiCoder
Last Activity: Feb 9 '11, 02:37 PM
Joined: Jul 28 '09
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • DelphiCoder
    replied to What is warning "C4090"?
    in C
    Thanks a lot. I was focusing on the WNDPROC parameter. You are right.
    See more | Go to post

    Leave a comment:


  • DelphiCoder
    started a topic What is warning "C4090"?
    in C

    What is warning "C4090"?

    I have the following function declared:

    Code:
    void RegisterMyClass(HINSTANCE hinst, 
                                WNDPROC wproc, char* clsName)
    My window procedure is defined as follows:

    Code:
    LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, 
                               WPARAM wParam, LPARAM lParam)
    I call "RegisterMyClas s" declared above as follows:

    Code:
    RegisterMyClass(hInstance,
    ...
    See more | Go to post

  • DelphiCoder
    replied to Advantage of unions.
    in C
    Unions can be thought of "variants" in other programming languages.
    See more | Go to post

    Leave a comment:


  • DelphiCoder
    replied to Converting a char to an int
    in C
    If you're really concerned, you can just write a function like this:

    Code:
    int CharToInt(char c)
    {
       char digits[] = "0123456789";
       int i;
       for (i=0; i<=9; i++)
          if (c == digits[i])
             return i;
       return -1;
    }
    Or perhaps this:
    Code:
    int CharToInt2(char c)
    {
       char *digits = "0123456789";
       char *pos
    ...
    See more | Go to post

    Leave a comment:


  • DelphiCoder
    replied to Animation using pure C/Win32
    in C
    Thanks so much! This is a great article. I will rewrite my app accordingly....
    See more | Go to post

    Leave a comment:


  • DelphiCoder
    replied to Animation using pure C/Win32
    in C
    So how do they make games that run on Windows?...
    See more | Go to post

    Leave a comment:


  • DelphiCoder
    replied to Animation using pure C/Win32
    in C
    I don't. It's a constant....
    See more | Go to post

    Leave a comment:


  • DelphiCoder
    replied to Animation using pure C/Win32
    in C
    I discovered the problem was with SleepEx(). I ran a diagnostics program that I wrote. It takes 157 ms to execute a loop containing 100 ms worth of SleepEx() calls on my work computer. On my home computer, it's exactly 100 ms.
    See more | Go to post

    Leave a comment:


  • DelphiCoder
    replied to Converting a char to an int
    in C
    By the way, I just tried your code in Visual C++ 2008, and it actually works just fine as is. The value of N4 is 4 (not 4000). The only thing I changed is I added (char *) before ReceivedStr:

    char *ReceivedStr = "P0004";

    But what I said earlier is still true if I'm understanding the C spec correctly. According to the specification of the C language, atoi requires a null-terminated string.
    See more | Go to post

    Leave a comment:


  • DelphiCoder
    replied to Converting a char to an int
    in C
    Instead of:
    PosToMoveTo = atoi(&N4);

    You can try:
    PosToMoveTo = (int) N4 - 48;

    I believe that atoi() expects a null-terminated string. A char is not necessarily followed by a null terminator in memory, so when you give atoi a pointer to a char, it just keeps reading the contents of memory until it hits the null-terminator. It doesn't know that the length of your "string" is just one chara...
    See more | Go to post

    Leave a comment:


  • DelphiCoder
    started a topic Animation using pure C/Win32
    in C

    Animation using pure C/Win32

    As part of familiarizing myself with the Win32 API, I wrote a simple animation program in C. The program has a struct for each bitmap, holding information such as its location, visibility, mask (for transparency), etc. Then I have a separate thread running that has a WHILE loop that looks like this:

    Code:
    WHILE (TRUE)
    {
       /* update all structs (bitmap locations, etc) */
       SleepEx(iSpeed, FALSE);
       InvalidateRect(hwnd,
    ...
    See more | Go to post

  • Thanks. I feel stupid. I did a search and found the answer on Google on how to make a GIF background transparent with "The Gimp". Now my photo browser looks semi-professional....
    See more | Go to post

    Leave a comment:


  • How do I make control "buttons" look transparent in Javascript?

    I wrote a gallery div where you see a photo, and at the top right corner of the photo I have images of arrows to go back and forth to see other photos, along with other controls.

    My question is: My "controls" images (which I drew by hand) have a black background. Is there a way to make the background transparent so that all I see on the photo is the control itself? If this is not doable in Javascript, is it doable in Photoshop,...
    See more | Go to post

  • DelphiCoder
    replied to Why does this code snippet not work in C ?
    in C
    Well duh. I do apologize. I actually spent a half hour struggling with it, never noticing the stupid mistake....
    See more | Go to post

    Leave a comment:


  • DelphiCoder
    replied to Why does this code snippet not work in C ?
    in C
    OK, I copied/pasted the code into my VC++ and it doesn't work. I get a 6 digit number instead of the expected string:

    Code:
    void SInit(char **s) { 
       *s = malloc(sizeof(char)*25); 
    } 
     
    
    int main() 
    { 
       char *str; 
       SInit(&str); 
       strcpy(str, "Hello, World"); 
       printf("%d", str); 
       free(str); 
       getch(); 
       return
    ...
    See more | Go to post

    Leave a comment:


  • DelphiCoder
    replied to Why does this code snippet not work in C ?
    in C
    ... and to change the value of the address itself, I need the address of the address....
    See more | Go to post

    Leave a comment:


  • DelphiCoder
    replied to Why does this code snippet not work in C ?
    in C
    Thanks a lot. I think I understand now. In most cases, we change the content of the memory block by passing a pointer to it into the function. But what I was trying to do here is change the actual pointer by making it point at a different block of memory, and to do that I have to pass a pointer to that pointer.

    Thanks for the explanation.
    See more | Go to post

    Leave a comment:


  • DelphiCoder
    replied to Why does this code snippet not work in C ?
    in C
    I guess there is a gap in my understanding that I wasn't aware of. I don't see why I need to pass a pointer to a pointer.

    For instance, given what you guys said, I don't understand why this code works. I'm changing the value inside the function and I don't need a pointer to a pointer to do it. There seems to be something about the "malloc" function that requires a pointer to a pointer, rather than just a pointer. "strcpy",...
    See more | Go to post

    Leave a comment:


  • DelphiCoder
    replied to Why does this code snippet not work in C ?
    in C
    I'm passing an address in the first post too. I understand that C parameters by value.

    Let me put it this way: Can you fix the code in the first post so that it works as intended? Maybe then I will understand what you're trying to tell me.
    See more | Go to post

    Leave a comment:


  • DelphiCoder
    replied to Why does this code snippet not work in C ?
    in C
    But I'm passing an address. You can do that in C. For example, this works:
    Code:
    void Init(int *n) {
       *n = 5;
    }
    
    int main()
    {
       int *i;
       i = malloc(sizeof(int));
       Init(i);
       printf("%d", *i);
       getch();
       return 0;
    }
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...