Click here to Skip to main content
15,889,808 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How can I append menu dynamically ? Pin
వేంకటనారాయణ(venkatmakam)13-Apr-11 1:04
వేంకటనారాయణ(venkatmakam)13-Apr-11 1:04 
GeneralRe: How can I append menu dynamically ? Pin
_Flaviu13-Apr-11 2:03
_Flaviu13-Apr-11 2:03 
GeneralRe: How can I append menu dynamically ? Pin
_Flaviu13-Apr-11 2:22
_Flaviu13-Apr-11 2:22 
AnswerRe: How can I append menu dynamically ? Pin
వేంకటనారాయణ(venkatmakam)13-Apr-11 3:33
వేంకటనారాయణ(venkatmakam)13-Apr-11 3:33 
GeneralRe: How can I append menu dynamically ? Pin
Klaus-Werner Konrad13-Apr-11 11:57
Klaus-Werner Konrad13-Apr-11 11:57 
GeneralRe: How can I append menu dynamically ? Pin
_Flaviu13-Apr-11 18:54
_Flaviu13-Apr-11 18:54 
GeneralRe: How can I append menu dynamically ? Pin
Klaus-Werner Konrad14-Apr-11 11:54
Klaus-Werner Konrad14-Apr-11 11:54 
QuestionHow to get the pixel color from a virtual device context ? Pin
wangningyu12-Apr-11 16:31
wangningyu12-Apr-11 16:31 
I want to get some gdi elements color infomation.

when I used TextOut function to draw the strings in the device context.but I doesn't want to output the strings in a really device context in the program's window. so I found this way :

#include <windows.h>

#pragma comment(lib,"user32.lib")

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pszCmdLine, int cmdShow)
{
    // create a virtual dc to draw elements.
    HDC		hdcScreen     = CreateDC("DISPLAY", NULL, NULL, NULL); 
    HDC		hdcCompatible = CreateCompatibleDC(hdcScreen);
    CString     m_strText = _T("Hello");
    SIZE        m_sz;
    
    if(hdcCompatible == NULL)
    {
        MessageBox(NULL,_T("CreateCompatibleDC Failed !"),NULL,NULL);
        return -1;
    }
    
    // then set the text color is black,the back color is white.
    SetBkColor(hdcCompatible,RGB(255,255,255));
    SetTextColor(hdcCompatible,RGB(0,0,0));
    
    // draw the text int a virtual dc.
    TextOut(hdcCompatible,0,0,m_strText,m_strText.GetLength());
	
    // get the text width and height.
    GetTextExtentPoint32(hdcCompatible,m_strText,m_strText.GetLength(),&m_sz);
    
    // get the pixel infomation.
    for(int i=0; i<m_sz.cx; i++)
    {
        for(int j=0; j<m_sz.cy; j++)
        {
            COLORREF color = GetPixel(hdcCompatible,i,j);
            if(color == RGB(255,255,255)
            {
                // do something.
            }
            else
            {
                // do something.
            }
        }
    }
}


the m_sz value is normal ( 8 * 16),but the color variables is invalied, because is usually is the backcolor.

( I doesn't want to draw it in the program windows and then call GetPixel function from screen,that's not so good ! Smile | :) )

why is it ,or is there any other way ?





Thans for your reply !

Best regards !
AnswerRe: How to get the pixel color from a virtual device context ? Pin
Gwenio12-Apr-11 19:11
Gwenio12-Apr-11 19:11 
QuestionHow to get Jpeg Properties from a jpg file? Pin
Bryan Anslow12-Apr-11 7:40
Bryan Anslow12-Apr-11 7:40 
AnswerRe: How to get Jpeg Properties from a jpg file? Pin
Chris Losinger12-Apr-11 7:49
professionalChris Losinger12-Apr-11 7:49 
AnswerRe: How to get Jpeg Properties from a jpg file? Pin
Luc Pattyn12-Apr-11 8:56
sitebuilderLuc Pattyn12-Apr-11 8:56 
GeneralRe: How to get Jpeg Properties from a jpg file? Pin
Bryan Anslow12-Apr-11 12:11
Bryan Anslow12-Apr-11 12:11 
Question.bmp file data to HBITMAP, How ? Pin
nitin312-Apr-11 4:54
nitin312-Apr-11 4:54 
AnswerRe: .bmp file data to HBITMAP, How ? Pin
Code-o-mat12-Apr-11 7:32
Code-o-mat12-Apr-11 7:32 
AnswerRe: .bmp file data to HBITMAP, How ? Pin
MicroVirus13-Apr-11 1:45
MicroVirus13-Apr-11 1:45 
QuestionCyclic dependency in header file Pin
pandit8411-Apr-11 23:43
pandit8411-Apr-11 23:43 
AnswerRe: Cyclic dependency in header file Pin
Niklas L12-Apr-11 1:36
Niklas L12-Apr-11 1:36 
AnswerRe: Cyclic dependency in header file Pin
CPallini12-Apr-11 3:02
mveCPallini12-Apr-11 3:02 
AnswerRe: Cyclic dependency in header file Pin
Stefan_Lang12-Apr-11 5:04
Stefan_Lang12-Apr-11 5:04 
GeneralRe: Cyclic dependency in header file Pin
pandit8412-Apr-11 21:04
pandit8412-Apr-11 21:04 
GeneralRe: Cyclic dependency in header file Pin
Stefan_Lang12-Apr-11 21:27
Stefan_Lang12-Apr-11 21:27 
QuestionCreateFromFile of COleClientItem fail Pin
MKC00211-Apr-11 22:57
MKC00211-Apr-11 22:57 
AnswerRe: CreateFromFile of COleClientItem fail Pin
Hans Dietrich11-Apr-11 23:09
mentorHans Dietrich11-Apr-11 23:09 
GeneralRe: CreateFromFile of COleClientItem fail Pin
MKC00211-Apr-11 23:14
MKC00211-Apr-11 23:14 

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.