|
And you can use "SetWindowText(..)" to do the same.
|
|
|
|
|
CWindow::Create!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
Hi, guyz.
Hope you can help me with this one.
I'm encountering a problem using BitBlt. I might implemented it wrong, please help me check it.
code:
.h: static CBitmap m_bitmap;
OnDraw(CDC *pDC)
{
CDC BitmapDc;
CBitmap *old_bitmap;
BitmapDC.CreateCompatibleDC(pDC);
old_bitmap=BitmapDC.SelectObject(&m_bitmap);
// Drawing code here
BitmapDc.Rectangle(top,bottom,right,bottom);
.....................
....................
//******************************
// 1st
CBitmap bitmap;
CDC memDC;
bitmap.LoadBitmap(L"START_BITMAP");
memDC.CretaeCompatibleDC(pDC);
BitmapDC.BitBlt(top,left,right,bottom,&memDC,0,0,SRCCOPY);
//******************************
// another drawing code for lines
................
.................
pDc->BitBlt(top,left,right,bottom,&BitmapDC,0,0,SRCCOPY);
BitmapDC.SelectedObject(old_bitmap);
// end of code
From the above code, there's no problem work as expected. Image appears at the background of the lines.
But, if i use HDC instead of the bitmap, the image were not seen and has been overlapped by a white fill.
//******************************
// 2nd
CDC memDC;
memDC.Attach(m_hDC);
BitmapDC.BitBlt(top,left,right,bottom,&memDC,0,0,SRCCOPY);
//******************************
// m_hDC was returned from other class
What is the difference with the 2?
Why is the image were not seen using the 2nd code
}
|
|
|
|
|
TooShy2Talk wrote: old_bitmap=BitmapDC.SelectObject(&m_bitmap);
Before SelectObject(), have you created m_bitmap??? if not use CreateCompaitbleBitmap() to create the bitmap. And since the m_bitmap is a member variable, you should create it only once.
|
|
|
|
|
Yes, it was already initialized.
Upon debugging, I noticed the effect of the BitmapDC.Rectangle().
The fill color that cover the image was somehow related to the Rectangle fill.
Is it possible to create rectangle(BitmapDC.Rectangle()) without fill?
But when 1st code is used this is not happening.
Do you know why?
|
|
|
|
|
TooShy2Talk wrote: Is it possible to create rectangle
Yes use the Draw3dRect() function for that. I thing Selecting a NULL brush to the BitmapDC and then calling the Rectangle() function will also work.
|
|
|
|
|
I have tried using
BitmapDc.SelectBrush(NULL_BRUSH);
before creating the rectangle
BitmapDC.Rectangle(left,top,right,bottom);
but then the cover fill become black.
The image is still invisible.
|
|
|
|
|
TooShy2Talk wrote: BitmapDc.SelectBrush(NULL_BRUSH);
SelectBrush()?? Is there function like that in the CDC class?
How about Draw3dRect() function?
|
|
|
|
|
hi all,
this is my function, for this how can assign the value.please help me
BOOL CACR120RWBLOCK1Dlg::VerifyKeyA(int SectorNo)
{
VerifyKeyA = false;
}
i am getting this error.
error C2659: '=' : overloaded function as left operand
thanku all,
savitri,
|
|
|
|
|
What are you trying to do ? VerifyKeyA is a function, not a variable.
Ah, I think I know. You know some VB, but you don't know C++ ? You need to create a new variable to return. Also, you should use bool, not BOOL, which is just a macro for people using C ( which did not have bool ). BOOL is an int.
boolCACR120RWBLOCK1Dlg::VerifyKeyA(int SectorNo)
{
bool result = false;
// insert code here to set result to true if appropriate.
return result;
}
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Lets see if I can explain this.
I have an app.exe (basically a test app) which loads, via LoadLibrary, mainDLL (which exports c-style functions as an api) that uses libraryDLL which contains class definitions which are exported.
app.exe passes hInstance to mainDLL via DllMain. mainDLL uses classes defined in LibraryDLL. It appears that libraryDLL is loaded everytime an exported class is used by mainDLL (as expected I guess, but this isnt my confused point)
The problem is when libraryDLL gets hInstance, its always the handle of app.exe and not mainDLL. I need libraryDLL to use retrieve mainDLL handle and name because other files are used based on the mainDLL name.
Questions:
- How do I get libraryDLL to get the handle of mainDLL?
- libraryDLL is always loaded first. Can I control this? I'm guessing I cant since its not an api dll but exported classes
- Why does mainDLL return the handle of app.exe when I call GetModuleHandle(NULL) instead of the handle for mainDLL?
- Do I need a DLLMain in both mainDLL and libraryDLL?
If so, should I use hInstance? If so, hInstance is always of the wrong module so why use it?
Is it apparent I"m confused? ANy help or articles to read would be appreciated.
TIA
-C
|
|
|
|
|
Wheatbread wrote: Why does mainDLL return the handle of app.exe when I call GetModuleHandle(NULL) instead of the handle for mainDLL?
First read the MSDN well. it says
"If this parameter is NULL, GetModuleHandle returns a handle to the file used to create the calling process (.exe file)."
The module handle of the mainDLL will be passed to the DllMain of the mainDLL ( HINSTANCE ). Save that HINSTANCE so that you can pass that value to the libraryDLL when need.
Another option is to use the below code to get the module handle
MEMORY_BASIC_INFORMATION stMemoryInfo; <br />
static int nAddress; <br />
if( !VirtualQuery( &nAddress, &stMemoryInfo, sizeof( stMemoryInfo ))<br />
!= 0 )<br />
{ <br />
return false; <br />
}<br />
HMODULE hModule = (HMODULE)stMemoryInfo.AllocationBase;
|
|
|
|
|
hi all,
in vb the function declaration is like this
Hex_Dec(val$, ByVal start As Byte) As Byte, how shall i declare the same fuction in VC++. please help me i am fresher.
thanku,
savitri
|
|
|
|
|
savitri wrote: Hex_Dec(val$, ByVal start As Byte) As Byte
What does this function do?
Maxwell Chen
|
|
|
|
|
hi maxwell Chen,
we use this to convert hex number but i am not getting how to declare that function why that $ is used..
Hex_Dec(Mid("FFFFFFFFFFFF", 1, 2), 1)
thanku
savitri
|
|
|
|
|
savitri wrote: we use this to convert hex number but i am not getting how to declare that function why that $ is used..
I don't quite get what you meant, and I do not read VB code / syntax.
I guess you are going to format a byte value in hexadecimal display. There are some existing functions for this job. You don't have to write your own.
Take a look at itoa function.
Or you can use the below:
char sTmp[10] = {0};
char val = 0xAB;
sprintf(sTmp, "%X", val);
Maxwell Chen
|
|
|
|
|
savitri wrote: but i am not getting how to declare that function why that $ is used..
Appending the identifier type character $ to any identifier forces it to the String data type.
So you neither know VB.
|
|
|
|
|
savitri wrote: Hex_Dec(val$, ByVal start As Byte) As Byte, how shall i declare the same fuction in VC++.
May be the following useful,
BYTE Hex_Dec(TCHAR *val, BYTE start);
But function and variable declaration are basics you need to learn these language constructs. Refer book, online tutorial, and compare with VB.
|
|
|
|
|
dear all
i would like to convert RGB image to grayscale, however i couldn't, how to convert y = Rx0.3+Gx0.59+Bx0.11) below?
int iWidth=m_vicImg.endx-m_vicImg.stx+1;
int iHeight=m_vicImg.endy-m_vicImg.sty+1;
int iBuffwidth=m_vicImg.buffwidth;
unsigned char *ucImgdata=m_vicImg.ibuff;
for(int iY=0;iY<iheight;iy++)>
{
for(int iX=0;iX<iwidth*3;ix+ mode="hold"> {
ucImgdata=(0.3*ucImgdata[iX+2] + 0.59*ucImgdata[iX+1] + 0.11*ucImgdata[iX]);
}
ucImgdata+=iBuffwidth;
}
error C2440: '=' : cannot convert from 'double' to 'unsigned char *'
i know ucImgdata type is different with what we signed in left, but i can't do correctly. anyone help me, thanks
Li Zhiyuan
|
|
|
|
|
li zhiyuan wrote: ucImgdata=(0.3*ucImgdata[iX+2] + 0.59*ucImgdata[iX+1] + 0.11*ucImgdata[iX]);
error C2440: '=' : cannot convert from 'double' to 'unsigned char *'
may be the following useful,
ucImgdata[iX+2] = ucImgdata[iX+1] = ucImgdata[iX] =(0.3*ucImgdata[iX+2] + 0.59*ucImgdata[iX+1] + 0.11*ucImgdata[iX]);
but i think the current available code is not written yourself. you need to be familiar with basic array, pointer concepts.
|
|
|
|
|
Rajkumar R wrote: but i think the current available code is not written yourself. you need to be familiar with basic array, pointer concepts.
People here keep telling him this, but he just doesn't listen ...
Maxwell Chen
|
|
|
|
|
Maxwell Chen wrote: People here keep telling him this, but he just doesn't listen ...
Right you say...!but could we try to find why yuo he don't want to listen.. any language problem, since by name he seems to no english speaking country!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
ThatsAlok wrote: but could we try to find why yuo he don't want to listen.. any language problem, since by name he seems to no english speaking country!
If I recall correctly, "li zhiyuan" is from China and now lives in Malaysia.
Maxwell Chen
|
|
|
|
|
ohh great!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
You code still doesnt look correct enough. In image processing, normally we write in this way;
x_start,y_start, x_end, y_end are the coordinates for your ROI (Region of Interest)
Also note, the RGB image is 24-bit (hence the 3 = 24/8). Array indexing is used as x*depth + y *depth*image width (not region width)
Also note, on IA-x86 (Intel Arch), RGB in memory comes as BGR
for(int y = y_start; y < y_end; y++)<br />
for(int x = x_start; x < x_end; x++)<br />
{<br />
pImageGray[x+y*width] = pImageRGB[x*3 + y*width*3 + 0]*0.112 + pImageRGB[x*3 + y*width*3 + 1]*0.59 + pImageRGB[x*3 + y*width*3 + 2]*0.33;<br />
<br />
}
|
|
|
|