home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / mswindo / programm / misc / 5473 < prev    next >
Encoding:
Text File  |  1993-01-28  |  2.6 KB  |  105 lines

  1. Newsgroups: comp.os.ms-windows.programmer.misc
  2. Path: sparky!uunet!charon.amdahl.com!amdahl!rtech!pacbell.com!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!The-Star.honeywell.com!umn.edu!gaia.ucs.orst.edu!sequent!muncher.sequent.com!tima
  3. From: tima@sequent.com (Timothy Alan Anderson)
  4. Subject: Strange BitBlt problem
  5. Message-ID: <1993Jan28.020801.20702@sequent.com>
  6. Sender: usenet@sequent.com (usenet )
  7. Nntp-Posting-Host: family.sequent.com
  8. Organization: Sequent Computer Systems Inc.
  9. Date: Thu, 28 Jan 93 02:08:01 GMT
  10. Lines: 93
  11.  
  12. My goal is to take two bitmaps, one 'mask' and one 'picture' and
  13. stuff it onto the screen so that you can leave the original screen
  14. colors alone (ala icons). In the process of trying to do that, I have been 
  15. unable to get a rather simple code section (a portion of what I was
  16. trying to work on) to work correctly. If anyone can give me a hint,
  17. I would be much appreciative...
  18.  
  19. Lets say that global_hdc is the 'global HDC' and hmono_bitmap is
  20. the handle to a monochrome bitmap. Assume these are set up correctly.
  21. Example code section follows:
  22.  
  23. HDC global_hdc;
  24. HBITMAP global_hmono_bitmap;
  25.  
  26. WindowsIsStupid(void)
  27. {
  28.    BITMAP bm;
  29.    HDC hdc_temp;
  30.    HDC hdc_mask;
  31.  
  32.    /* coupla compatible dc's */
  33.    hdc_temp = CreateCompatibleDC(global_hdc);
  34.    hdc_mask = CreateCompatibleDC(global_hdc);
  35.  
  36.    /* So that the mono bitmap comes in as */
  37.    /* WHITE background and BLACK forground*/
  38.    SetTextColor(hdc_mask, RGB(0,0,0));
  39.    SetBkColor(hdc_mask, RGB(255,255,255));
  40.  
  41.    /* standard windows garbage */
  42.    GetObject(global_hmono_bitmap, sizeof(BITMAP), &bm);
  43.    SelectObject(hdc_temp, global_hmono_bitmap);
  44.  
  45. #if 1
  46.  
  47.    /* this section doesn't work */
  48.  
  49.    BitBlt(hdc_mask,
  50.       0,
  51.       0,
  52.       bm.bmWidth,
  53.       bm.bmHeight,
  54.       hdc_temp,
  55.       0,
  56.       0,
  57.       SRCCOPY);
  58.  
  59.    /* hdc_mask should have a color converted copy of the afore */
  60.    /* mentioned monochrome bitmap. */
  61.  
  62.    BitBlt(global_hdc,
  63.       0,
  64.       0,
  65.       bm.bmWidth,
  66.       bm.bmHeight,
  67.       hdc_mask,
  68.       0,
  69.       0,
  70.       SRCCOPY);
  71.  
  72.    /* global_hdc should have an exact copy of the above */
  73.    /* but it doesn't display anything at all.... */
  74.  
  75. #else
  76.  
  77.    /* this does work, so hdc_temp is OK after SelectObject */
  78.  
  79.    /* So that the mono bitmap comes in as */
  80.    /* WHITE background and BLACK forground*/
  81.    SetTextColor(global_hdc, RGB(0,0,0));
  82.    SetBkColor(global_hdc, RGB(255,255,255));
  83.  
  84.    BitBlt(global_hdc,
  85.       0,
  86.       0,
  87.       bm.bmWidth,
  88.       bm.bmHeight,
  89.       hdc_temp,
  90.       0,
  91.       0,
  92.       SRCCOPY);
  93.  
  94. #endif
  95.  
  96.    DeleteDC(hdc_temp);
  97.    DeleteDC(hdc_mask);
  98.  
  99. }
  100.  
  101. What is going on?
  102.  
  103. tima@sequent.com
  104.  
  105.