|
I dont understand you have one function SetBitmap(UINT nIDResource) now
you want to pass SetBitmap(CBitmap *pBitmap); to this function or your problem
CBitmap mBitmap
whitesky
|
|
|
|
|
Suppose we have a class:
class CBitmapViewer : public CWnd
{
...
public:
CBitmap m_Bitmap; // the BMP is loaded here
CRect R; // the whole window size
public:
virtual BOOL Create(CWnd* pParentWnd, const RECT& rect, UINT nID,
DWORD dwStyle = WS_VISIBLE);
BOOL SetBitmap(UINT nIDResource);
};
I am creating the picture 1:
CRect RPicture1(10, 10, 200, 200);
mPicture1 = new CBitmapViewer();
mPicture1->Create(this, RPicture1, ID_OBRAZEK);
mPicture1->SetBitmap(IDB_BITMAP_CHILD);
I am creating the picture 2:
CRect RPicture2(10, 220, 200, 410);
mPicture2 = new CBitmapViewer();
mPicture2->Create(this, RPicture2, ID_OBRAZEK);
mPicture2->SetBitmap(IDB_BITMAP_CHILD);
There are two picture on the screen.
Now the user can mark the part of the first window.
This coorinates are placed in CRect Rf.
Now, I am cutting down a part of the picture one - using the Rf coordinates:
int mWidth = Rf.Width();
int mHeight = Rf.Height();
CBitmap bmp_part;
bmp_part.CreateBitmap(mWidth, mHeight, 1, 24, NULL);
// get the bitmap size
BITMAP bitmap_size;
bmp_part.GetObject(sizeof(BITMAP), &bitmap_size);
// get a bitmap's part from Picture1 and place them into the bmp_part
unsigned char *pData2 = new unsigned char[bitmap_size.bmHeight * bitmap_size.bmWidthBytes];
mPicture1->m_Bitmap.GetBitmapBits(bitmap_size.bmHeight * bitmap_size.bmWidthBytes, pData2);
bmp_part.SetBitmapBits(bitmap_size.bmHeight * bitmap_size.bmWidthBytes, pData2);
delete[] pData2;
/*
when I have a part of the Picture1 in the bmp_part a want to replace a Picture2 with bmp_part.
*/
For example using:
mPicture2.Assign(&bmp_part);
or I can to create the new object:
mNewBitmap = new CBitmapViewer();
mNewBitmap->Create(this, R3, ID_OBRAZEK3); // CRect R3 - where the window is placed
mNewBitmap->AssignBitmap(&bmp_part);
From this moment I want some help, becouse I don't know how to do it
Regards
|
|
|
|
|
Hope I understood your question
<br />
void CAnswerDlg::OnBnClickedTest()<br />
{<br />
CBitmapViewer *mNewBitmap;<br />
CBitmap bmp_part;<br />
bmp_part.Attach((HBITMAP)LoadImage(AfxGetInstanceHandle(),"c:\\0.bmp",IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION));<br />
<br />
CRect R3;<br />
mNewBitmap = new CBitmapViewer();<br />
mNewBitmap->Create(this, R3, 1);
mNewBitmap->SetBitmap2(&bmp_part);<br />
mNewBitmap->DestroyWindow();<br />
<br />
<br />
}<br />
<br />
BOOL CBitmapViewer::Create(CWnd* pParentWnd, const RECT& rect,UINT nID,DWORD dwStyle)<br />
{<br />
return CWnd::Create("CBitmapViewer","",dwStyle,rect,pParentWnd,1,0);<br />
}<br />
<br />
BOOL CBitmapViewer::SetBitmap(UINT nIDResource)<br />
{<br />
return m_Bitmap.LoadBitmap(nIDResource);<br />
}<br />
<br />
void CBitmapViewer::SetBitmap2(CBitmap *m)<br />
{<br />
m_Bitmap.Attach((HBITMAP)m->m_hObject);<br />
}<br />
whitesky
|
|
|
|
|
gomez_a wrote: How can I get a HBITMAP, when I have only CBitmap bmp3?
CBitmap::operator HBITMAP
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi Guys,
A structure,which consists of member variables ( eg: int, float data type ) is written in a shared memory from a BackEnd application, which is accessed by a Front End application. When I try to write a Cstring variable or TCHAR array as member variable of the structure, it is not working, and exception occurs. Actually my need is to write a string to shared memory - from Back end, which is accessed by Front End. The string should be a member of this structure. So plz help me what datatype to be used.
Thanks in Advance
Velayudhan
|
|
|
|
|
velayudhan_raj wrote: A structure,which consists of member variables ( eg: int, float data type ) is written in a shared memory from a BackEnd application, which is accessed by a Front End application. When I try to write a Cstring variable or TCHAR array as member variable of the structure, it is not working, and exception occurs. Actually my need is to write a string to shared memory - from Back end, which is accessed by Front End. The string should be a member of this structure. So plz help me what datatype to be used.
Try Char* instead.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Actually I am working in Unicode support application. so I tried with TCHAR* , but it is not working.
A doubt : CString can't be written in Shared memory, as we cannot define the size of CString , Is it correct?
|
|
|
|
|
velayudhan_raj wrote: Actually I am working in Unicode support application. so I tried with TCHAR* , but it is not working.
Give Specfic Size to the String Member, i.e. USE TCHAR youObj[100];
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
A possible solution is to define a fixed-size array within your shared structure, for instance: TCHAR mName[100] . The size of the array must be large enough. Now for string-transfer operations use string-manipulation functions like strcpy in non-Unicode or wcscpy in Unicode mode. (If you use lstrcpy or StrCpy , then they will work in both modes).
Unfortunately, this is problematic to use if you cannot predict and limit the largest size of your string.
|
|
|
|
|
See Here[^] maybe it is some helpful to you
whitesky
|
|
|
|
|
If the two applications are complete separate processes, you cannot just share pointers between the two of them. If the shared memory segment is coherent between both processes, you can simply use a portion of it as a buffer for text/string data. You can then pass offsets into the buffer to specify data locations.
Or, you can change the structure to contain a proper array and copy the entire structure to the shared memory area:
struct sMyData
{
double m_dValue;
char m_cValue;
char m_caValue[ 128 ];
int m_iValue;
}; When moving data between processes via some kind of shared memory implementation, you should generally avoid pointers and "real" objects.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
I have created a simple WIN32 Consol application that prints a message "hi how are you"
It compiles fine , but when I run it it gives
Fatal error Kernal32.lib required
how it can be removed
Regards.
|
|
|
|
|
Under project settings>Linkd>object library modules check if kernel32.lib exists.
If not add it.
Could be some other issue?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
zahid_ash wrote: Fatal error Kernal32.lib required
You are receiving this message at run-time?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I'm trying to develop compiler with flex and bison....
does anybody have tutorial or ebook on buidling compiler with flex and bison on visual c++
Thank you....
|
|
|
|
|
|
Hi,
Thanx for info....but do you have information related to MS visual c++
Regards
|
|
|
|
|
I used the following code. But it does not take the correct column (subitem).
The part of code is in OnMouseMove event:
void CListt::OnMouseMove(UINT nFlags, CPoint point)
{
CPoint pt(point);
ScreenToClient(&pt);
LVHITTESTINFO hitInfo;
hitInfo.pt = point;
int nItem = -1;
nItem = m_list.SubItemHitTest(&hitInfo);
if (nItem >= 0)
{
m_list.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED);
}
if (nItem >= 0 && hitInfo.iSubItem > 0)
{
int m_nSubItemHit = hitInfo.iSubItem;
if ( hitInfo.iSubItem == 8)
SetCursor(hCursor);
}
}
I need to change the cursor if subitem is "8". But even if move the mouse on the 8th subitem, the value of hitInfo.iSubItem is some thing else. moreover nItem is always -1.
Any clues please
Thanks
Raji
|
|
|
|
|
Hi guys
can i convert
integers and doubles to _bstr_t;
if yes can you tell me how
thanks a lot
|
|
|
|
|
_bstr_t is a type which can hold unicode string.
CString strText;
// format the value to CString
strText.Format("%d",nValue);
call strText.AllocSysString(); to convert
SaRath.
"Don't Do Different things... Do Things Differently..."
|
|
|
|
|
SaRath C wrote: _bstr_t is a type which can hold unicode string.
you getting very fast
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
SaRath C wrote: call strText.AllocSysString(); to convert
there can Memory Leak problem here!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
antonaras wrote: integers and doubles to _bstr_t;
//Integer
TCHAR szStr[100];
wsprintf(szStr,"%d",100);
_bstr_t bstText(szStr);
//Float
TCHAR szStr[100];
wsprintf(szStr,"%f",100.10);
_bstr_t bstText(szStr);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
ThatsAlok wrote: TCHAR szStr[100];
wsprintf(szStr,"%d",100);
I think type defined by TCHAR has dependency to the current build environement(unicode/ MBCS). The compiler will define char array instead of unicode character array (wchar_t)in an MBCS environment. so there is a chance for error. I think, when it is better to declare wchar_t array instead of declaring TCHAR array since we are using wsprintf for formatting. what do u think?
SaRath.
"Don't Do Different things... Do Things Differently..."
|
|
|
|
|
SaRath C wrote: I think type defined by TCHAR has dependency to the current build environement(unicode/ MBCS). The compiler will define char array instead of unicode character array (wchar_t)in an MBCS environment. so there is a chance for error.
Actually TCHAR is defined as :-
#ifdef UNICODE
#define TCHAR wchar_t
#else
#define TCHAR char
#endif so you can use in both Character set. plus little mistake from my side too, wsprintf should be written something like this to make it character set independent
wsprintf(szChar,_T("%d"),100);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|