|
Harold_Wishes wrote: Will I need to overload the << operator to output each element of the data object to the screen?
You don't need to per se, but you could. Either way, you should create a print method that looks like either of the following:
ostream& operator<<(ostream& os, const data& dta)
{
os << dta.Length.c_str() << endl
<< dta.Sequence.c_str() << endl
<< dta.N_Terminal.c_str() << endl
<< dta.C_Terminal.c_str() << endl;
return os;
}
void print(const data& dta)
{
cout << dta.Length.c_str() << endl
<< dta.Sequence.c_str() << endl
<< dta.N_Terminal.c_str() << endl
<< dta.C_Terminal.c_str() << endl << endl;
}
void print(const data& dta)
{
cout << dta << endl;
}
for_each(g_DataList.begin(), g_DataList.end(), print);
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Hi,
my email sending with Simple MAPI works, sort of.
But send mail is stuck in the outlook outbox
and has to be mailed from there..
I have looked the examples in here, haven't
found a clue for this problem.
I have also tried the trick, where I send the
mail in first session and then make a second
session with MAPI_FORCE_DOWNLOAD on, but that
doesn't help either.
Any ideas?
|
|
|
|
|
Hy, I have this code and this error which I don't understand. Any help will be very apreciated. Thank you.
this is test1.cpp:
#include <iostream.h>
class Address
{
private:
int house;
int block;
public:
Address(int i, int j) {
house=i;
block=j;
}
friend ostream& operator << (ostream&, const Address&);
};
ostream& operator << (ostream& a, const Address& b)
{
a<<"House No "<
|
|
|
|
|
I suppose you have to move your implementation of operator << to test1.cpp (or other *.cpp) file.
I hope it helps.
-- modified at 10:56 Friday 7th July, 2006
|
|
|
|
|
mosu` wrote: this is test1.cpp:
The following code should be moved to a header file (you should not be including *.cpp files!):
In test1.h
#pragma once
#include <ostream>
class Address
{
private:
int house;
int block;
public:
Address(int i, int j) : house(i), block(j)
{ }
int GetHouseNumber() const { return house; }
int GetBlockNumber() const { return block; }
};
inline ostream& operator<<(ostream& a, const Address& b)
{
a << "House No " << b.GetHouseNumber() << endl;
a << "Block Number " << b.GetBlockNumber() << endl;
return a;
};
And in main.cpp
#include "test1.h"
int main()
{
Address a(10,113);
cout << a;
return 0;
}
The error is due to the fact that test1.cpp is being compiled twice in your code and thus has multiple definitions in the object code.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Hello
How to run an application within an application : inside a dialog-based application, I want to run another one inside a rectangle ?
Thank you
|
|
|
|
|
Hi,
You can create a process using CreateProcess and can set it size in STARTUP_INFO parameter.
see msdn for more details.
AFAIK it is not possible to show that exe insde your appliaction, unless it's a COM control (ActiveX or DLL). I'm not sure about this.
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
<blink>My Blog | Understanding State Patte
|
|
|
|
|
Sarath.<fon wrote:<="" div="">AFAIK it is not possible to show that exe insde your appliaction, unless it's a COM control (ActiveX or DLL). I'm not sure about this.
If the application is simple enough, you can wrap it in an ActiveX control and have it run inside that. Also, if the application exposes itself via COM (like the office components), you can have it appear on a dialog, but it won't look like the full application in most cases.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
In the case of a notepad or wordpad what? what we can do with that?
Office system is completely developed as COM Components and many applications using it very well. that is what I said, we can't make inside as our control or part of our application unless it is an attachable manner.
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
<blink>My Blog | Understanding State Patte
|
|
|
|
|
Do you mean to embed one dialog in another? You could (probably should) do so in the same application. In fact, you can glue the two dialogs together forever. To do it properly:
In the client area of your container dialog, create a child window (rectangle). Pass this child window as the paranet of your embeded dialog.
Best,
Jun
|
|
|
|
|
Hello,
I'm using a CListCtrl in a CListView to show my data and now I want my data to be shown in a grphical form (with rectangles, circles, lines and so on). For testing, I decided to do this on a right mouse double-click an I implemented the following:
void kstkoardwView::OnRButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: Code für die Behandlungsroutine für Nachrichten hier einfügen und/oder Standard aufrufen
//Test for Graphik
CClientDC dc(this);
CListCtrl &listCtrl = GetListCtrl();
RECT rect;
for (int i = 0; i <= 6; i++)
{
listCtrl.DeleteColumn(0);
}
GetClientRect(&rect);
dc.Rectangle(rect.left, rect.bottom, rect.right, rect.top);
int b = (int) (100.0 * rand() / RAND_MAX);
dc.TextOut(point.x-100, point.y-100, "Hugo");
dc.Ellipse(point.x-b, point.y-b, point.x+b, point.y+b);
dc.Rectangle(point.x-b+100, point.y-b+100, point.x+b, point.y+b);
dc.Rectangle(10, rect.bottom, 20, rect.bottom-100);
dc.Rectangle(20, rect.bottom, 30, rect.bottom-75);
dc.Pie(100, 100, 150, 150, 300, 300, 250, 250);
dc.Draw3dRect(200,200,300,300,0,0);
CListView::OnRButtonDblClk(nFlags, point);
}
But following happens: First double-click = Columns are deleted - the gray header-row is still visible. Second doble-click = the rest is done and I see my drawing.
Can anyone tell me why and a solution? Or has anyone a better solution to make graphics from CListView-data?
Thanks, Gerhard
|
|
|
|
|
If I understand what you are trying to do correctly, you have some data displayed in a ListView and the user can select an option to display it in a different way?
That being the case, you are going about it the wrong way. You should be creating another view that displays the data the way you want it. When the user turns on that view, you display it. This article should help get you started after you write the code for your new view.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Thanks for your answer,
I'm using MDI and till now (at the beginning) I have already about 10 DocTemplates. So I hoped, I can make the graphic (for each of this templates) without making a new one.
But regardless of this your answer helped me. I recogniced, that I have only to make a new View (and use the old Doc).
Thanks, Gerhard
|
|
|
|
|
Hello all,
i'm trying to display a Bitmap in a Picture Control. The picture is captured by a CMOS camera (gray), and all i have is a pointer to the image in the Framegrabber buffer. The problem is that i don't have a real bitmap in that buffer, just an array with pixel values. The technical support of the Framgrabber producer couldn't help me till now and i'm still waiting for thier reply . I was trying to create a Bitmap manualy and fill in all the needed structures like BITMAPINFO and so on but nothing worked. Can you tell me how to construct a bitmap from an pixelarray, just knowing the lenght, width and that's it is gray scale picture.
I would be very greatfull for any kind of help!
I wish you a nice Weekend
im79
|
|
|
|
|
Gray as in 8-bits per pixel? Did you set up the color table? Show how you're calling CreateDIBitmap and your input values (BITMAPINFO).
|
|
|
|
|
Hello all, hello hrfy and thanks for your answer
Yes it is 8-bits per pixel. I didn't set the color table. I just called CreateBitmap or DIBitmap passing width, length, the pointer to the pixel array and so on. I as i explaind in my first posting, i don't have a BITMAPINFO, can make one manualy?
I tried manythings but nothing worked. I'm new to windows programming and MFC.
I'm not at work now, so i don't have the source code here right now.
Eventhough i cann't provide enough info, i hope u can still help me on this one
Kind regards and thanks again ,
im79
|
|
|
|
|
im79 wrote: i don't have a BITMAPINFO, can make one manualy?
If you know what kind of data is in the pixel array, you should have no problem populating the header.
I've just written and tested this by generating a grayscale gradient and it works.
HBITMAP CreateGrayscaleBitmap(int nWidth, int nHeight, LPBYTE pData)
{
BITMAPINFO *pbmi = (BITMAPINFO*) new BYTE[sizeof(BITMAPINFO) + (sizeof(RGBQUAD) * 256)];
ZeroMemory(pbmi, sizeof(BITMAPINFO));
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pbmi->bmiHeader.biWidth = nWidth;
pbmi->bmiHeader.biHeight = -nHeight;
pbmi->bmiHeader.biPlanes = 1;
pbmi->bmiHeader.biBitCount = 8;
pbmi->bmiHeader.biCompression = BI_RGB;
pbmi->bmiHeader.biSizeImage = nWidth * nHeight;
RGBQUAD *pColors = pbmi->bmiColors;
for(int i = 0; i < 256; i++)
{
pColors->rgbBlue = i;
pColors->rgbGreen = i;
pColors->rgbRed = i;
pColors->rgbReserved = 0;
pColors++;
}
CWindowDC dc(NULL);
HBITMAP hBitmap = CreateDIBitmap(dc, &pbmi->bmiHeader, CBM_INIT, pData, pbmi, DIB_RGB_COLORS);
delete pbmi;
return hBitmap;
}
This is for a top-down bitmap. If your image is flipped, remove the negative sign in front of the height.
|
|
|
|
|
Hi, i've tried your code in my appicaltion and have another problem now . I need a CBitmap object, so i tried the following:
<br />
CDC *pDC = GetDC();<br />
CBitmap* myBitmap;<br />
<br />
myBitmap = CBitmap::FromHandle(hBitmap);<br />
myBitmap->CreateCompatibleBitmap(pDC, m_iWidth, m_iHeight);<br />
myBitmap->LoadBitmap(IDC_STATIC_PICTURE);
I get an Unhandled exception in wingdi.cpp line 1102:
<br />
BOOL CGdiObject::Attach(HGDIOBJ hObject)<br />
{<br />
ASSERT(m_hObject == NULL);
if (hObject == NULL)<br />
return FALSE;<br />
CHandleMap* pMap = afxMapHGDIOBJ(TRUE);<br />
ASSERT(pMap != NULL);<br />
pMap->SetPermanent(m_hObject = hObject, this);<br />
return TRUE;<br />
}<br />
This is the call stack:
>mfc71d.dll!CGdiObject::Attach(void * hObject=0x0305061d) Line 1102 + 0x1c C++
mfc71d.dll!CBitmap::CreateCompatibleBitmap(CDC * pDC=0x00816af4, int nWidth=400, int nHeight=400) Line 217 + 0x25 C++
I hope you can help me again here
im79
|
|
|
|
|
im79 wrote: myBitmap->CreateCompatibleBitmap(pDC, m_iWidth, m_iHeight);
What are you trying to do here?
im79 wrote: myBitmap->LoadBitmap(IDC_STATIC_PICTURE);//picture control in my dialog
The CBitmap::LoadBitmap function is used to load an image into the bitmap, not set an image into a picture control...
|
|
|
|
|
hfry wrote: im79 wrote:
myBitmap->CreateCompatibleBitmap(pDC, m_iWidth, m_iHeight);
What are you trying to do here?
I thought that i have to convert the DIB to a DDB Bitmap, so i guess that's wrong
I just want to display the Bitmap in a picture control, but it's not as easy as i thought
hfry wrote: The CBitmap::LoadBitmap function is used to load an image into the bitmap, not set an image into a picture control...
Yes that's stupid, I should have read the MSDN manuals
|
|
|
|
|
im79 wrote: it's not as easy as i thought
It is actually.
CStatic *picture = (CStatic*) GetDlgItem(IDC_STATIC_PICTURE);
picture->SetBitmap(hBitmap);
Make sure the static control's type is actually set to Bitmap.
|
|
|
|
|
Hi hfry
It's working
Thank you very much
|
|
|
|
|
Hi
i need your (or any one's) help again
I'm trying for long time to change this code in order to make an 8Bit color Bitmap but it's not working
I'll be greatfull for any help!
|
|
|
|
|
Hi,
RGBQUAD *pColors = pbmi->bmiColors;
for(int i = 0; i < 256; i++)
{
pColors->rgbBlue = i;
pColors->rgbGreen = i;
pColors->rgbRed = i;
pColors->rgbReserved = 0;
pColors++;
}
The code snippet above is setting the color table. In your previous question, you wanted it grayscale so the color table so I set it up as such. If you want it to be color you need to setup the appropriate color table that your 8-bit data maps to.
Regards,
Justin Tay
|
|
|
|
|
I have two very simple classes as shown below. In my application code, I want to test the
condition of the object - is it valid? But, VC++ tells me :
"error C2248: 'IsValid' : cannot access public member declared in class 'CBaseFile'"
Why? Why? For goodness' sake, why? Is it not declared public? It looks like it, it even tells
me it is public. What obvious goof don't I see?
{
// app code snippet:
CSpecialFile *pSpecialFile = new CSpecialFile("a filename");
if (!pSpecialFile->IsValid()) AfxMessageBox("Oh no!!! Mr. Bill...");
}
class CBaseFile
{
public:
CBaseFile(CString sFilename);
virtual ~CBaseFile();
bool IsValid();
private:
bool m_bIsValid; // true if no problems encountered;
};
Then I inherit from it...
class CSpecialFile: CBaseFile
{
public:
CSpecialFile(CString sFilename);
virtual ~CSpecialFile();
// more methods specific to special file object go here....
};
Charlie Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
My son's PDA is an M249 SAW.
|
|
|
|
|