|
How does this code even compile?
Chuck Vought wrote: lastname += letters[i%2][rand()%letterlength[i%2]];
Study this statement carefully.
Aside from that, your code produces:
Zyr Yayaouyeea
Yyv Yoiooioeyu
Qay Yiuooeyoeu
Zyh Uyiaauuiuu
Rok Ioiouiaooi
Les Oyauaiuiyu
Xam Aoieyuiaoy
Mij Oyeaaaoiya
Yuq Yyiuaoyooa
Hil Uayayyouyu which falls within your guidelines of a 3-letter first name and a 10-letter last name.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
From what you've shown num, numFirst and numLast have not been declared.
they are variables so how could i declare them? they are declared as int types.
|
|
|
|
|
Chuck Vought wrote: they are variables so how could i declare them? they are declared as int types.
http://www.codeproject.com/Messages/3160966/Re-Random-Name-Generator.aspx[^]
When you are asking for help and providing code snippets, the less guess work we have to do, the better. Since I am not you, I have no way of knowing if the compiler errors you reference go hand-in-hand with the code snippets you are providing.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
i can send the .cpp file if you want to run it to see the errors do you want me to do that?
|
|
|
|
|
LOL, what a discussion
Why don't you post to let us know how you did at the exam or whatever it was?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
I do want to post a message thanking all of you who helped me finish this program and get the code to do what I needed it to do. Especially David who was very,very helpful. Just to let you know I did pass and actually got a 100%. Once again thanks to all for your help. It was much appreciated.
|
|
|
|
|
Hi,
I'd like get some idea how to do it?
I displayed BMP image(full screen) in OnPaint fuction of SDI CView Window.(it's OK );
I'd like to flow a strings over the BMP image form right-bottom to left-bottom.
it is just like subtitle on TV...
How can I approach it to do it?
because I'm VC beginner ... Any comment will help..
Have a day.
|
|
|
|
|
in painting you draw at first the background and than draw the top painting stuff. So in your case you first draw the bmp and than draw the text. To draw nice the you got to create a own Font (CFont).
Here is some API-code:
BOOL DrawTextTransparent(HDC hdc, HFONT hFont, const RECT& rc, LPCTSTR pszText, UINT cnt)
{
HFONT hFontOld = (HFONT) ::SelectObject( hdc, hFont );
int iBkMode = ::SetBkMode( hdc, TRANSPARENT );
BOOL b = ::ExtTextOut( hdc, rc.left, rc.top, ETO_CLIPPED, &rc, pszText, cnt, 0 );//read the help
::SetBkMode( hdc, iBkMode );
::SelectObject( hdc, hFontOld );
return b;
}
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hi,
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?
Another problem is that, after load the image i need to minimize my windows and open it again, the image just can show.= =ll.
i'm still new in MFC..Anyone can help me?Thx
|
|
|
|
|
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....
|
|
|
|