|
that will work if you have the bitmap in the resource.
if you are using the bitmap from file, then use the following code,
HBITMAP hBitmap; //Declare in Class
hBitmap = (HBITMAP)::LoadImage(NULL, "C:\\filename.bmp", IMAGE_BITMAP, 0,0,LR_LOADFROMFILE); //in Constructor
::DeleteObject(hBitmap); //in destructor
//Add in WM_CTLCOLOR handler
if (CTLCOLOR_DLG == nCtlColor)
hbr = ::CreatePatterhBrush(hBitmap);
|
|
|
|
|
thanks
but these are errors
'CreatePatterhBrush' : is not a member of '`global namespace''
'CreatePatterhBrush' : undeclared identifier
'=' : cannot convert from 'int' to 'struct HBRUSH__ *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
in the
hbr = ::CreatePatterhBrush(hBitmap);
Ashish Dogra
MCA
Noida
|
|
|
|
|
ashish dogra wrote: 'CreatePatterhBrush' : is not a member of '`global namespace''
'CreatePatterhBrush' : undeclared identifier
It helps to spell the function correctly.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
thats
::CreatePatternBrush(..)
|
|
|
|
|
if you want to use brush in ctlcolor use
<br />
CBrush *m_brush;<br />
CBitmap m_Bitmap;<br />
m_Bitmap.Attach(LoadImage(...));<br />
m_brush=new CBitmap(&m_Bitmap);<br />
now in ctlcolor return m_brush->GetSafeHandle();//i think this (GetSafeHandle) i dont have vc now
in the end delete m_brush
whitesky
|
|
|
|
|
i want to display different bitmaps of digital no. in subclass static control.i have created an array of handle of HBITMAP and i am getting all the handle in constructor. when i am trying to access from a click of button in dialog its not displaying the digit.
code is below:
// this the derived class constructor
CNewstatic::CNewstatic()
{
for(int i=0;i<=11;i++)// code for getting the handle
{
HBITMAP temp = (HBITMAP)::CreateMappedBitmap(AfxGetApp()->m_hInstance, IDB_BITMAP1+i, 0, NULL, 0);
m_hBitmap[i] = (HBITMAP)::CopyImage( temp, IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG | LR_COPYDELETEORG);
}
}
after a button click i am accessing the objects in a method//
void CNewstatic ::OutPut(int digit,int pos)
{
CRect rect;
GetClientRect(&rect);
m_w = rect.Width()/8;
m_h = rect.Height();
pos =0;
//CBitmap* pBitmap ;//CBitmap::FromHandle( m_hBitmap[digit]);
CClientDC dc(this);
CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
//pBitmap->LoadBitmap(IDB_BITMAP1);
CBitmap* pBitmap = CBitmap::FromHandle( m_hBitmap[0]);
CBitmap* pOldBitmap = dcMem.SelectObject(pBitmap);
dcMem.SelectObject(pOldBitmap);
int f = dc.StretchBlt(m_w*pos, 0, m_w, m_h,
&dcMem, 0, 0, m_bm.bmWidth, m_bm.bmHeight, SRCCOPY);
if(f)
AfxMessageBox("Create");
else
AfxMessageBox("Not Create");
dcMem.DeleteDC();
}
it gives create message after clicking the button but image is not displayed .
please tell me the reason and solution of the problem.
|
|
|
|
|
rkshdixit wrote: dcMem.SelectObject(pOldBitmap);
My guess is that you're selecting out your bitmap too early...
|
|
|
|
|
actually i am displaying the bitmap after the calculation it will change display bitmap after 1 sec is it early.
|
|
|
|
|
I don't think you understood me. You are selecting your bitmap out before you do the stretchblt. You should select out your bitmap after the stretchblt. I'm actually not sure why you are using CClientDC though. Are you drawing in response to WM_PAINT? Because then you would have a CPaintDC and you should be doing the drawing with it.
|
|
|
|
|
I use windows forms in my project. This project must have multilanguage support. How can I load string from resource (String table) without using MFC. But If mfc is adaptable into windows forms, may be it is used. I don't know this.
|
|
|
|
|
You can use LoadString(..) or LoadResource(..)
Both are Platform SDK functions and not MFC related
|
|
|
|
|
Thanks for your fast replying. How can I use this methods or functions? (LoadStrıng or LoadResource)
|
|
|
|
|
like that :
CString strMainTitle;
strMainTitle.LoadString(IDS_MAINTITLE);
this->SetWindowText(strMainTitle);
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
CString is in MFC library. But I must load string without using MFC library.
|
|
|
|
|
|
|
int LoadString( HINSTANCE hInstance,
UINT uID,
LPTSTR lpBuffer,
int nBufferMax
);
Unfortunately, I couldn't understand first parameter of this function. Can you explain this parameter?
|
|
|
|
|
int LoadString( HINSTANCE hInstance,
UINT uID,
LPTSTR lpBuffer,
int nBufferMax
);
Unfortunately, I couldn't understand first parameter of this function. Can you explain?
|
|
|
|
|
If the StringTable is in the same application then you can pass NULL as first parameter
|
|
|
|
|
"error C3861: 'LoadString': identifier not found, even with argument-dependent lookup"
Can you tell me that what is the reason of this error? All the parameter of this functon are correct as given below.
TCHAR sz[160];
LoadString(NULL,IDYES,sz,sizeof(sz));
|
|
|
|
|
check by incuding "windows.h"
|
|
|
|
|
mehmetned wrote: How can I use this methods or functions? (LoadStrıng or LoadResource)
See here.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
First of all i'm working in a MDI evironment
I want to create a CDialog that would kind off stay on the background of all other windows so i've placed it in the MainFrm Object:
VERIFY(pMainFrame->m_InitialDlg.Create(CInitialDlg::IDD, pMainFrame));
VERIFY(pMainFrame->m_InitialDlg.SetWindowPos(&wndBottom, 0, 0, 0, 0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE));
The trouble is that m_InitialDlg stays on top of all the other Windows (the Doc/View/Frame ones) Any ideea how to fix this?
Is there a beter way of doing it that does not require the CDialog..?
-- modified at 5:01 Tuesday 11th July, 2006
|
|
|
|
|
eusto wrote: The trouble is that m_InitialDlg stays on top of all the other Windows (the Doc/View/Frame ones) Any ideea how to fix this?
Set the dialog's parent to NULL . Since the MDI frame is the parent hence it stays on top of it.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
Tried it with null also it's still a modal window and hence it has top most style (as opposed to views)
|
|
|
|