|
As per your original post you said the program gets an array.
myarray is assumed to be that array.
If you do not have it, you got to create it.
You could create a string variable and use string::Format instead of Console::WriteLine to do what you want to do.
They are very similar.
|
|
|
|
|
Please show me how to fix this fragment so it will compile and run in a console application
Cstring stuff;
for( i = 0, i < 80; i++ )
stuff += char(i);
Console::Writeline( stuff );
Thanks for your time
|
|
|
|
|
You're mixing up stuff here.
CString is an MFC/ATL class and Console::WriteLine is a .Net C++/CLI method.
I'm guessing you're using MFC, in which case you cannot use Console::WriteLine .
Use printf instead like this - printf("%s", stuff);
If you're doing a UNICODE build you must must either use wprintf instead of printf or use printf like so - printf("%S", stuff);
|
|
|
|
|
Yes, I know it does not work. That's why I'm here. Lets try again:
<unknown> show_stuff;
for( i = 0; i < 80; i++)
show_stuff[0] = <some_function>( i );
Console::Writeline( show_stuff );
Please correct my errors and re-write into something that will compile with C++ in a Visual Studio 2008 console application.
Thanks for your time
|
|
|
|
|
char show_stuff[80];
for (int i = 0; i < 80; ++i)
show_stuff[i] = i;
printf("%s\n", show_stuff); This will not give you the desired output as some elements of the array are data that cannot he printed.
|
|
|
|
|
I was hoping to find something more up to date than just an array of bytes. But I'll forget that and forget the CONSOLE::Write() options and just use the concept of:
char some_str[80];
int index = 0;
int low = (int)'A';
int high = (int) 'z';
for( int i = 50; i< 110; i ++ )
{
if( i >= low && i <= high )
some_str[index] = (char) i;
else
some_str[index] = '.';
index ++;
}
some_str[ index ] = 0;
printf( "data: %s", some_str );
Thanks for your time
|
|
|
|
|
You are asking in the wrong forum: C/C++/MFC is for native code. Your code snippet use the .NET Framework then the right forum is Managet C++/CLI
|
|
|
|
|
is this the fastest way to access the RGB values of a pixel of a bitmap file in c#?
the code is below
bm is previously declared Bitmap object.
Collapse
BitmapData bmd=bm.LockBits(new Rectangle(0, 0, 10, 10), System.Drawing.Imaging.ImageLockMode.ReadOnly, bm.PixelFormat);
int PixelSize=4;
for(int y=0; y<bmd.Height; y++)
{
byte* row=(byte *)bmd.Scan0+(y*bmd.Stride);
for(int x=0; x<bmd.Width; x++)
{
row[x*PixelSize]=255;
}
}
OR is there more faster way exists to access the RGB values of a pixel in C# or in VC++?
if in VC++ we can access the RGB values more faster than this so please help me.
and if the above method is the fastest way and no other faster method exists than this in c# or in VC++ so please comment as well.
thanks
|
|
|
|
|
That is the fastest way, as you access directly to the raw data of the image. Anyway, be aware that you are assuming the bitmap to be 32 bpp; you code will not work properly with 24 bpp, 16 bpp, 8 bpp, grayscale and B/W bitmaps.
|
|
|
|
|
inayathussaintoori wrote: Is this the fastest way
No, it isn't. Calling a property in a for test is a bad idea. And you're in the wrong forum.
|
|
|
|
|
sir in which forum should i post this question?
|
|
|
|
|
Where you have already posted it! I've just seen the same post on the C# forum.
Please, don't cross post; it's too much better to choose the right forum and post a question only once.
|
|
|
|
|
In the C# forum is fine, as you are using C#; and not here, your question does not relate to C/C++/MFC.
|
|
|
|
|
yes you are right and thanks for the comment but i have posted my question in both forums because i was thinking that c++ may have faster way to access the pixels than c#.infact i was confused therefore i had posted in the both forums..
thanks to all of you.
|
|
|
|
|
While talking about bitmap manipulation, you can do almost the same things with C/C++ and C#. Be aware that if an API is not available in C# you can always use the P-Invoke to access it.
|
|
|
|
|
Hi,
Please tell me how can i replace the default list box of a combo box with a custom made one. I have made a subclassed listbox. I want to show this listbox when user clicks on the down arrow of combo box.
Thanks in advance,
John.
|
|
|
|
|
|
Thanks for the link.
I was trying the approach described in the following link
How to subclass CListBox and CEdit inside of CComboBox
I have created an ownerdrawn combobox and subclassed CComboBox and overridded all required methods such as[OnDrawItem,MeasureItem,etc] and WM_CTLCOLOR. I can see the code hits the OnDrawItem,MeasureItem,etc but it is never coming to OnCtlColor.
Can someone help me by pointing out what i am doing wrong?
HBRUSH CComboBoxEx2::OnCtlColor(CDC *pDC,CWnd *pWnd,UINT nCtlColor)<br />
{<br />
<br />
<br />
if (nCtlColor == CTLCOLOR_EDIT)<br />
{<br />
<br />
}<br />
else if (nCtlColor == CTLCOLOR_LISTBOX)<br />
{<br />
<br />
}<br />
HBRUSH hbr = CComboBox::OnCtlColor(pDC, pWnd, nCtlColor);<br />
return hbr;<br />
<br />
}<br />
<br />
void CComboBoxEx2::DeleteItem(LPDELETEITEMSTRUCT lpDeleteItemStruct)<br />
{<br />
<br />
}<br />
<br />
void CComboBoxEx2::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)<br />
{<br />
<br />
<br />
CComboBox::DrawItem(lpDrawItemStruct);<br />
}<br />
<br />
void CComboBoxEx2::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)<br />
{<br />
<br />
CComboBox::MeasureItem(lpMeasureItemStruct);<br />
}<br />
<br />
int CComboBoxEx2::CompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct)<br />
{<br />
<br />
<br />
return 0;<br />
}
|
|
|
|
|
How can I change the background color of my CComboBox , but only in the edit area , not dropdown list ?
I have something like :
class CStatusCombo : public CComboBox
and here :
HBRUSH CStatusCombo::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CComboBox::OnCtlColor(pDC, pWnd, nCtlColor);
switch(nCtlColor)
{
case CTLCOLOR_LISTBOX:
pDC->SetTextColor(RGB(0, 255, 0));
pDC->SetBkColor(RGB(120,120,120));
return (HBRUSH)(m_pEditBkBrush->GetSafeHandle());
}
return hbr;
}
I change background of the list area , not the edit area of the combo ... I would like to change the color of edit area just like the statusbar color ... it could be soemthing like that ?
modified on Saturday, October 23, 2010 2:03 PM
|
|
|
|
|
Doesn't CTLCOLOR_EDIT work?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|
|
No , I try but didn't work ...
|
|
|
|
|
How about CTLCOLOR_STATIC?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|
|
It was go with CTLCOLOR_EDIT , but only when I type letters into combo control , when not the background color remain white ...
|
|
|
|
|
I just realized that you are hancling the control-color message in the combo box itself, not in its parent. Did you try with ON_WM_CTLCOLOR_REFELECT or ON_WM_CTLCOLOR?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|
|
You have to subclass the edit control of the combo box, since a combo box is a combined control. Here is an article[^] from Microsoft support describing how to do so.
|
|
|
|