|
You can use the CString::Tokenize[^] method by specifying "," as the token delimiter.
You can get the count by incrementing a variable in the while loop in the example in the above link.
|
|
|
|
|
Hi all,
dialog box in my application having so many controls.i want to print it.
i want to print dialog box screen.
please tell me how can i do this.
thank in advance.
|
|
|
|
|
I've answered a similar question in the QA section some time ago.
Check out my answer[^] which contains a working example.
|
|
|
|
|
its working fine thanks.
but dialog size display smaller than its real size.
|
|
|
|
|
Set your printer resolution same as your screen resolution and the problem should gone.
Another approach is to create the bitmap of the dialog based on the printer resolution, but in some cases
(on high resolution printers) this can generate huge bitmaps, so setting the printer resolution is easier and safer.
|
|
|
|
|
Nice piece of code and certainly worth a 5.
It's time for a new signature.
|
|
|
|
|
Thank you very much Richard!
|
|
|
|
|
its not display the OnPaint graphics in image.
|
|
|
|
|
Le@rner wrote: its not display the OnPaint graphics in image.
I'm not sure what you mean.
There is not OnPaint method in my code.
There is only OnPrint and it is working as expected, prints the dialog.
|
|
|
|
|
i draw a header on dialog box in OnPaint function.
|
|
|
|
|
In that case you should draw it again in on the bitmap of the dialog.
This can be done in OnPrint method.
Here is a snippet from the method with comments to show you where you can draw:
void CDlgTestDlg::OnPrint(CDC *pDC, CPrintInfo* pInfo)
{
HBITMAP hWndBmp = GetWndBmp(GetSafeHwnd());
RECT rect;
GetWindowRect(&rect);
int nWidth = rect.right - rect.left;
int nHeight = rect.bottom - rect.top;
CDC dcSrc;
dcSrc.CreateCompatibleDC(NULL);
const int nRestorePoint = dcSrc.SaveDC();
dcSrc.SelectObject(hWndBmp);
pDC->BitBlt(0, 0, nWidth, nHeight, &dcSrc, 0, 0, SRCCOPY);
dcSrc.RestoreDC(nRestorePoint);
dcSrc.DeleteDC();
DeleteObject(hWndBmp);
}
|
|
|
|
|
|
You are welcome!
|
|
|
|
|
One more query,
OnPaint graphics overlap with image and not display exactly same as dialog display,
if i draw graphics on OnPrint again.
there is any other option to print dialog with Paint graphics.
thanks.
|
|
|
|
|
This happens because the viewport of the bitmap dc is not synchronized with the client rect of the dialog.
Try something like that:
void CDlgTestDlg::OnPrint(CDC *pDC, CPrintInfo* pInfo)
{
HBITMAP hWndBmp = GetWndBmp(GetSafeHwnd());
RECT rect;
GetWindowRect(&rect);
int nWidth = rect.right - rect.left;
int nHeight = rect.bottom - rect.top;
CDC dcSrc;
dcSrc.CreateCompatibleDC(NULL);
const int nRestorePoint = dcSrc.SaveDC();
dcSrc.SelectObject(hWndBmp);
CRect rcClient, rcWindow;
GetWindowRect(rcWindow);
GetClientRect(rcClient);
CRect rcClientMoved(rcClient);
rcClientMoved.MoveToXY((rcWindow.Width() - rcClient.Width()) / 2,
(rcWindow.Height() - rcClient.Height() - GetSystemMetrics(SM_CYBORDER)));
CPoint ptViewPortOrg = dcSrc.GetViewportOrg();
dcSrc.SetViewportOrg(rcClientMoved.TopLeft());
dcSrc.SetViewportOrg(ptViewPortOrg);
pDC->BitBlt(0, 0, nWidth, nHeight, &dcSrc, 0, 0, SRCCOPY);
dcSrc.RestoreDC(nRestorePoint);
dcSrc.DeleteDC();
DeleteObject(hWndBmp);
}
This should do the job!
|
|
|
|
|
Hi, how to use iterators in file stream can any one explain me with sample code, that read and write files using iterator
|
|
|
|
|
Please explain what you are trying to achieve. Files and iterators are two completely different concepts.
|
|
|
|
|
Really? I was under the impression that istream_iterator and ostream_iterator were for exactly that purpose.
|
|
|
|
|
Looking at the other replies, I realized that I misunderstood his question. I thought that he wanted to serialize a container and use the iterators to save the data. that's why I asked him more information.
|
|
|
|
|
something like that (snatch from a google search):
std::ifstream ifs("filename.txt");
std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
?
Watched code never compiles.
|
|
|
|
|
Maximilien wrote: std::ifstream ifs("filename.txt");std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
Something like this is much faster,
std::ifstream stream("c:\\test.txt");
if (stream.good())
{
std::stringbuf buf;
stream>>&buf;
std::string str(buf.str());
stream.close();
}
|
|
|
|
|
|
At the risk of sounding glib, you can use stream iterators with any stream, whether they're from memory, sockets, files.
So if I have a lump of integers in a vector:
int init_data[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
std::vector<int> data( &int_data[0], &int_data[10] );
I can pump them out to any stream using the copy algorithm. So:
std::copy( data.begin(), data.end(), std::ostream_iterator<int>( std::cout, "\n" ) );
will write that lot out to std::cout separated by newlines. If you replace std::cout with the name of an ofstream then those values will tbe written to the file instead. Replace it with the name of an ostringstream and the data will end up in a string.
To read from a stream is much the same, except you use an istream_iterator:
std::vector<int> data;
std::copy( std::istream_iterator<int>( std::cin ), std::istream_iterator<int>(), std::back_inserter( data ) );
will read integers from standard in until something goes wrong with the stream (end of file, I/O error, run out of memory) and dump them at the back of data.
And of course it's not just copy - you can use any std algorithm that can handle input/output iterators. So as two examples you can transform a file into another one or accumulate the values in another. Basically any single pass operation you can do on a list or vector you can do on a file or pair of files in the same manner.
Cheers,
Ash
|
|
|
|
|
If you want to learn about iterators, I can recommend that you implement a few. It's a great way of learning what it is, the difference between the various types, forward/random access/bidirectional/etc, and in what situations an iterator is a good or bad choice. It's also a great lesson in efficiency as well as a way of getting to know stl in general a bit better.
|
|
|
|
|
Hey there guys,
Okay I have my current code working for GLFW. Effectively i'm just trying to build a small main-frame which I can build on. I have IniApi.cc that stores the main() routine. I have CharKeyCallback.cc which handles the glfwSetCharCallback() just fine.
However, i'm trying to make a Texture class which will load textures from a file and store them in memory. So, I placed this at the top of the Texture.cc file:
#include <Windows.h>
#include <GL/glfw.h>
#include <stdio.h>
#include "Texture.h"
And my "load" function works like this:
bool Texture::ReadImage()
{
glfwReadImage(_filename, ImageData, _flags);
return !(ImageData == NULL);
}
(If it appears messy or simple, it's because i'm just laying the foundations at the moment).
However, when I go to compile, I receive the following error:
error LNK2019: unresolved external symbol _glfwReadImage referenced in function "public: bool __thiscall Texture::ReadImage(void)" (?ReadImage@Texture@@QAE_NXZ)
Now, my InitApi.cc runs the lpfw functions just fine, which means the library & DLL have been loaded (glfwOpenWindow opens a window successfully) but Texture.cc won't recognise the lpfw functions, even though i've included #include <GL/glfw.h> at the top.
Any suggestions? Thank you
|
|
|
|