|
ok. i think the second problem i had solve it already.
just add the UpdateAllViews()...
The 1st problem still there..please advise.
|
|
|
|
|
You should be a bit more specific about your problem. Just saying something like "i have a button and if i press it what happens is not what i want, how can i fix it" won't tell us much about the actual problem. Show us some code snipplet, how do you load images into your 4 picture controls? Also, by "first image disappears" do you mean the newly loaded image "overwrites" the first one or the first one simly disappears from sight?
Since you say you have 4 pic controls and 4 buttons i guess that each pic control has a button which if you press, an image should be loaded into the corresponding picture control. I also guess that if you press the second button, not your second pic control gets the image but your first, and that is your problem. If so, i can generally think of 3 things that could cause this:
1. All 4 of your buttons have the same command ID (or at least, some buttons share the same command ID), thus, no matter which button you press, your program will get the same command ID and execute the same handler function which loads and image into the first picture control. Make your buttons have different command IDs so you can differentiate between them in code.
2. In the message map you specified the same function as a message handler for the buttons, so whichever button is pressed, the same function will be executed and will load the picture in the first picture control overwriting whatever was there previously.
3. Copy-paste bug, you have separate command IDs and separate handlers for your buttons but you copy-pasted the same code into each message handler and forgot to change the needed parts to make the handler load the image into the picture control belonging to the actual button, so whenever a button is pressed, the same code is executed and loads the picture into the first picture control.
Does any of this make sense?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Sorry for inconvenient.ok, i try to explain more detail.
In my dialog, i have 4 picture control to display the picture 1 -> picture 4
4 radio button to select picture 1->picture 4, and 1 button(Load Image button).
When the users click on the load image, the program will check the radio button now is on which picture, then load and display the picture into picture control.eg, if radio button now is on picture3,then the image must display in picture control number 3.
I had done this step,the image can display correctly. But when i click on another radio button,let say picture 2, the image previous show in picture control 3 will disappear. This is my problem now.but when i click back into radio button 3,it will show the previous image..
The image had store in memory..er..sorry for my poor English.hope you all can understand wat i saying...
|
|
|
|
|
Show some code, for example show us the code that runs when you hit the "Load" button and also the code that runs when a radio is selected (if any).
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
hi,below is my partially code.
void CTest::OnRadioDirection(UINT nID)
{
switch(nID)
{
case IDC_1:
id = 0;
break;
case IDC_2:
id = 1;
break;
case IDC_3:
id = 2;
break;
case IDC_4:
id = 3;
default:
break;
}
m_pGUIDoc->UpdateAllViews(NULL);
}
void CTest::DrawPreview(CDC* pDC)
{
if (m_pImg[id])
{
BYTE* pImg = (BYTE*)m_pImg[id]->imageData;
CvSize size = cvGetSize(m_pImg[id]);
CRect rcPreview;
if (id == 0)
GetDlgItem(IDC_picture1)->GetWindowRect(&rcPreview);
else if (id == 1)
GetDlgItem(IDC_PICTURE2)->GetWindowRect(&rcPreview);
else if (id == 2)
GetDlgItem(IDC_PICTURE3)->GetWindowRect(&rcPreview);
else if (id == 3)
GetDlgItem(IDC_PICTURE4)->GetWindowRect(&rcPreview);
else
;
ScreenToClient(&rcPreview);
double scaleX = (double)size.width / (double)rcPreview.Width();
double scaleY = (double)size.height / (double)rcPreview.Height();
double scaleToFit = (scaleX > scaleY) ? scaleX : scaleY;
int iWidth = (int) ((double)size.width / scaleToFit);
int iHeight = (int) ((double)size.height / scaleToFit);
int iOffX = rcPreview.left;
int iOffY = rcPreview.top;
HDC hDC = pDC>GetSafeHdc();
SetStretchBltMode(hDC, COLORONCOLOR);
StretchDIBits(hDC, iOffX, iOffY, iWidth, iHeight,
0, 0, size.width, size.height, pImg, GetBitmapTag(), DIB_RGB_COLORS, SRCCOPY);
}
}
The program is using the opencv to do the image processing.
modified on Thursday, August 13, 2009 10:14 PM
|
|
|
|
|
When do you call DrawPreview?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
in OnPaint function
void CTest::OnPaint()
{
CPaintDC dc(this);
DrawPreview(&dc);
}
|
|
|
|
|
As far as i can say, your code does exactly what you told it to do, it will draw the picture and only that picture which you selected using the radio buttons. However, i believe what you actually want is to draw all 4 images in your DrawPreview, not only the one that the radio selection indicates, right. So instead of checking that id of yours do -for example- a for loop that draws all 4 pictures if they are there. For example:
void CTest::DrawPreview(CDC *pDC)
{
UINT PicCtrlIDs[] = {IDC_Picture1, IDC_Picture2, IDC_Picture3, IDC_Picture4};
for (int i = 0; i < 4; i++)
if (m_pImg[i])
{
CWnd *PicControl = GetDlgCtrlItem(PicCtrlIDs[i]);
...
..
}
}
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Hi,
Your help me a lot Code-o-mat, now my picture control can show all the image already.Thank you
|
|
|
|
|
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
DevelopmentNoob wrote: Now i got 4 picture control and 4 button in 1 dialog. I can load the image into picture control, but when i load the second picture, the 1st image will disappear. How to make it fix to there?
How could we remotely guess what kind of code produces such annoying result?
In other words, without code is very hard helping you.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
im creating combobox ctrl Thru code but not from resource...and Pls let me know how can i increase the height of the ctrl based on the font...ie if the font is small ctrl should be small else if the Font is bigger Ctrl should increase....
|
|
|
|
|
You can do this by getting the combo box's font (GetFont/WM_GETFONT), calculating the height of the font (GetTextMetrics) and then changing the height of the control (SetWindowPos).
1300 calories of pure beef goodness can't be wrong!
|
|
|
|
|
Thanks for ur reply...
but the issue is i need to set the Combobox font and height based on the CFont* which i get from some other function which we are using internally ....
and even i tried doing SetFont for that Ctrl...but it doesn"t helped me...
|
|
|
|
|
The combo box has an edit control and a list control associated with it so you will need to change the font for those controls as well. You can retrieve a handle to these child controls with a call to GetComboBoxInfo().
1300 calories of pure beef goodness can't be wrong!
|
|
|
|
|
ya im able to get the hwnd to both Editbox and listCtrl but...how can i setfont for the obtained handles....
|
|
|
|
|
Hello Friends
I creatd application in which i m creating a thuumnail using HBITMAP .
Now I want to Insert a small Image(Logo) on that Bitmap that i creatd using HBITMAP.
I m able to write text on that using TextOut but how i can insert image on that?
Thanks in advance
Yogesh
|
|
|
|
|
Look at BitBlt or StretchBlt.
Basically, you create two DCs and select the source and destination bitmaps into each on and Blt away.
|
|
|
|
|
Ya,I got it already.thanks anyway for ur help.
|
|
|
|
|
Hi,
i need source code on how to check whether a new picture has upload in the folder.
the source code have to be in VB.
Thanks
|
|
|
|
|
monitor a folder in Win32 programme.
There are two windows API : FindFirstChangeNotification and ReadDirectoryChangesW.
it's my pleasure to make friend with you.
|
|
|
|
|
i doing in visual studio 2005. Can you write the whole code for me. Thanks alot
|
|
|
|
|
ok,tell me your email, i will send you soon.
it's my pleasure to make friend with you.
|
|
|
|
|
|
but i need the source code in VB
|
|
|
|