Click here to Skip to main content
13,139,515 members (53,225 online)

ATL / WTL / STL

 
AnswerRe: Intermediate GUI Techniques Pin
Richard MacCutchan2-Nov-12 6:20
mvpRichard MacCutchan2-Nov-12 6:20 
Questionproblem with sprintf_s() on win 7 Pin
Member 93537761-Nov-12 21:34
memberMember 93537761-Nov-12 21:34 
AnswerRe: problem with sprintf_s() on win 7 Pin
Richard MacCutchan1-Nov-12 22:50
mvpRichard MacCutchan1-Nov-12 22:50 
GeneralRe: problem with sprintf_s() on win 7 Pin
bkelly132-Nov-12 3:16
memberbkelly132-Nov-12 3:16 
GeneralRe: problem with sprintf_s() on win 7 Pin
Richard MacCutchan2-Nov-12 6:15
mvpRichard MacCutchan2-Nov-12 6:15 
GeneralRe: problem with sprintf_s() on win 7 Pin
Member 93537764-Nov-12 16:34
memberMember 93537764-Nov-12 16:34 
GeneralRe: problem with sprintf_s() on win 7 Pin
Richard MacCutchan4-Nov-12 21:26
mvpRichard MacCutchan4-Nov-12 21:26 
AnswerRe: problem with sprintf_s() on win 7 Pin
H.Brydon26-Nov-12 19:36
memberH.Brydon26-Nov-12 19:36 
Questionwsageterror() Pin
bkelly131-Nov-12 15:28
memberbkelly131-Nov-12 15:28 
AnswerRe: wsageterror() Pin
Richard MacCutchan1-Nov-12 22:48
mvpRichard MacCutchan1-Nov-12 22:48 
QuestionSTL map issue in VS2010 Pin
Subhash Madhukar30-Oct-12 3:47
memberSubhash Madhukar30-Oct-12 3:47 
AnswerRe: STL map issue in VS2010 Pin
Richard MacCutchan30-Oct-12 6:04
mvpRichard MacCutchan30-Oct-12 6:04 
Questionhow do i copy a CImage DIB to clipboard Pin
Member 951640015-Oct-12 11:15
memberMember 951640015-Oct-12 11:15 
AnswerRe: how do i copy a CImage DIB to clipboard Pin
Andrew Cherednik15-Oct-12 11:41
memberAndrew Cherednik15-Oct-12 11:41 
It fails because the memory allocated by GlobalAlloc is not enough. See, how you use sizeof(BITMAPINFO) + w * h * 3 value to allocate memory, and then you are trying to calculate the m_dwSizeImage value, which is much greater then requested.

You have got two options:
Either move this chunk of code after you have calculated the image size, so that your code becomes:
    DWORD dwBytes = ((DWORD) w * Bpp) / 32;
    
    if(((DWORD) w * Bpp) % 32) {
       dwBytes++;
    }
    dwBytes *= 4;
   
    unsigned long m_dwSizeImage = dwBytes * h; // no compression
 
    void* pBits = tmpImage.GetBits();
    HANDLE hData = ::GlobalAlloc (GMEM_MOVEABLE, sizeof(BITMAPINFO) + m_dwSizeImage);
    LPVOID pData = (LPVOID) ::GlobalLock (hData);
    LPBYTE p_imagebits;
    p_imagebits  = (LPBYTE)pData + sizeof(BITMAPINFO);
    
 
    memcpy(pData,&bmInfo,sizeof(BITMAPINFO));
    memcpy (p_imagebits, pBits, m_dwSizeImage);



Or, just use a solution[^] from Codeguru

BTW, it looks like you have calculated the m_dwImageSize incorrectly anyway
QuestionWhy does this fail - CFile / SeekToEnd? Pin
charlieg10-Oct-12 6:43
membercharlieg10-Oct-12 6:43 
AnswerRe: Why does this fail - CFile / SeekToEnd? Pin
charlieg10-Oct-12 9:31
membercharlieg10-Oct-12 9:31 
AnswerRe: Why does this fail - CFile / SeekToEnd? Pin
Andrew Cherednik10-Oct-12 11:23
memberAndrew Cherednik10-Oct-12 11:23 
GeneralRe: Why does this fail - CFile / SeekToEnd? Pin
charlieg11-Oct-12 2:20
membercharlieg11-Oct-12 2:20 
AnswerRe: Why does this fail - CFile / SeekToEnd? Pin
Richard MacCutchan10-Oct-12 21:45
mvpRichard MacCutchan10-Oct-12 21:45 
GeneralRe: Why does this fail - CFile / SeekToEnd? Pin
charlieg11-Oct-12 2:30
membercharlieg11-Oct-12 2:30 
GeneralRe: Why does this fail - CFile / SeekToEnd? Pin
charlieg11-Oct-12 4:53
membercharlieg11-Oct-12 4:53 
GeneralRe: Why does this fail - CFile / SeekToEnd? Pin
Richard MacCutchan11-Oct-12 11:19
mvpRichard MacCutchan11-Oct-12 11:19 
GeneralRe: Why does this fail - CFile / SeekToEnd? Pin
charlieg11-Oct-12 11:34
membercharlieg11-Oct-12 11:34 
GeneralRe: Why does this fail - CFile / SeekToEnd? Pin
Richard MacCutchan11-Oct-12 12:01
mvpRichard MacCutchan11-Oct-12 12:01 
GeneralRe: Why does this fail - CFile / SeekToEnd? Pin
charlieg12-Oct-12 5:54
membercharlieg12-Oct-12 5:54 
AnswerRe: Why does this fail - CFile / SeekToEnd? Pin
Stephen Hewitt11-Oct-12 12:58
memberStephen Hewitt11-Oct-12 12:58 
AnswerRe: Why does this fail - CFile / SeekToEnd? Pin
charlieg18-Jan-13 1:47
membercharlieg18-Jan-13 1:47 
QuestionKeep program open and running Pin
Lucidation8-Oct-12 11:23
memberLucidation8-Oct-12 11:23 
AnswerRe: Keep program open and running Pin
Richard MacCutchan8-Oct-12 22:14
mvpRichard MacCutchan8-Oct-12 22:14 
GeneralRe: Keep program open and running Pin
Lucidation9-Oct-12 11:14
memberLucidation9-Oct-12 11:14 
GeneralRe: Keep program open and running Pin
Richard MacCutchan9-Oct-12 11:19
mvpRichard MacCutchan9-Oct-12 11:19 
AnswerRe: Keep program open and running Pin
Stephen Hewitt11-Oct-12 21:45
memberStephen Hewitt11-Oct-12 21:45 
QuestionUSBView Compile Error Pin
Jim Fell5-Oct-12 10:17
memberJim Fell5-Oct-12 10:17 
AnswerRe: USBView Compile Error Pin
Wes Aday5-Oct-12 10:33
memberWes Aday5-Oct-12 10:33 
GeneralRe: USBView Compile Error Pin
Jim Fell10-Oct-12 8:04
memberJim Fell10-Oct-12 8:04 
QuestionFree memory allocated by std::multimap Pin
khaliloenit4-Oct-12 2:41
memberkhaliloenit4-Oct-12 2:41 
AnswerRe: Free memory allocated by std::multimap Pin
pasztorpisti6-Oct-12 15:26
memberpasztorpisti6-Oct-12 15:26 
AnswerRe: Free memory allocated by std::multimap Pin
Stephen Hewitt11-Oct-12 21:53
memberStephen Hewitt11-Oct-12 21:53 
GeneralRe: Free memory allocated by std::multimap Pin
pasztorpisti11-Oct-12 22:53
memberpasztorpisti11-Oct-12 22:53 
Questionhow to import COM interface methods in Win32 dll? Pin
litu kumar30-Sep-12 19:58
memberlitu kumar30-Sep-12 19:58 
AnswerRe: how to import COM interface methods in Win32 dll? Pin
«_Superman_»1-Oct-12 21:29
member«_Superman_»1-Oct-12 21:29 
GeneralOff topic Pin
Richard MacCutchan2-Oct-12 2:55
mvpRichard MacCutchan2-Oct-12 2:55 
GeneralRe: Off topic Pin
«_Superman_»2-Oct-12 3:00
member«_Superman_»2-Oct-12 3:00 
GeneralRe: Off topic Pin
Richard MacCutchan2-Oct-12 3:23
mvpRichard MacCutchan2-Oct-12 3:23 
QuestionTooltip for ATL toolbar Pin
Sakhalean24-Sep-12 18:43
memberSakhalean24-Sep-12 18:43 
QuestionCAsyncSocket Send( arguments ) Pin
bkelly1318-Sep-12 16:13
memberbkelly1318-Sep-12 16:13 
AnswerRe: CAsyncSocket Send( arguments ) Pin
Richard MacCutchan18-Sep-12 21:50
mvpRichard MacCutchan18-Sep-12 21:50 
GeneralRe: CAsyncSocket Send( arguments ) Pin
bkelly1319-Sep-12 12:13
memberbkelly1319-Sep-12 12:13 
AnswerRe: CAsyncSocket Send( arguments ) Pin
pasztorpisti29-Sep-12 23:52
memberpasztorpisti29-Sep-12 23:52 
GeneralRe: CAsyncSocket Send( arguments ) Pin
Richard MacCutchan30-Sep-12 1:07
mvpRichard MacCutchan30-Sep-12 1:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy |
Web04 | 2.8.170915.1 | Last Updated 17 Sep 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid