|
I want to ask about how to use startdoc(), startpage() to print data on paper imediately then receive the next data and print imediately and receive the next data and print ......
Example : If I want to print this below data in first page imediately and after that I receive the other data and print imediately not like Microsoft word which must receive all data and print 1 time.
110011110
How to do that loop?
This below is my program want to do that.
If first data is 110011110
I change 1 in the above data to solid black (which have 2 pixel width and 4 pixel height) and 0 in the above data to solid white (which have 2 pixel width and 4 pixel height)
code:
------------------------------------------------------------
DOCINFO di ;
CPrintInfo printInfo ;
CString filename ;
CDC dc ;
CRect draw_area ;
CPrintDialog dlg(FALSE) ;
if (Dlg.DoModal() == IDCANCEL)
return ;
HDC hDC = dlg.GetPrinterDC() ;
if (hDC == NULL)
return ;
di.cbSize = sizeof(DOCINFO) ;
di.lpszDocName = "Document name"
di.lpszOutput = NULL ;
// prepare the print information structure
dc.Attach(hDC) ;
printInfo.m_bDirect = TRUE ;
printInfo.m_rectDraw.left = 0 ;
printInfo.m_rectDraw.right = dc.GetDeviceCaps(HORZRES) ;
printInfo.m_rectDraw.top = 0 ;
printInfo.m_rectDraw.bottom = dc.GetDeviceCaps(VERTRES) ;
draw_area = printInfo.m_rectDraw ;
dc.StartDoc(&di) ;
//receive first data
CString testline = "110011110" ;
int x = 0 ;
int y = 0 ;
int pos = 0 ;
// start printing the document
dc.StartPage() ;
CBrush brush;
// Creation of the brush with a black color
brush.CreateSolidBrush(RGB(0, 0, 0));
while (pos < testline.GetLength())
{
if ((testline.GetAt(pos)) == '1')
{
// Create a rectangle with coordinates x,y,x+2,y+4 corresponding with top, left, bottom, right
CRect Rectangle(x, y, x + 2, y + 4) ;
// Fill a rectangle in the current device context or DC
dc.FillRect(&Rectangle , &brush);
x += 2;
}
else if ((testline.GetAt(pos)) == '0'){
x += 2;
}
pos++ ;
}
y += 4 ;
x = 0 ;
pos = 0 ;
dc.EndPage() ;
printInfo.m_rectDraw = draw_area ;
//OnEndPrinting(&dc, &printInfo);
dc.EndDoc() ;
VERIFY(dc.DeleteDC()) ;
------------------------------------------------------------
|
|
|
|
|
Or if you can show me the example how to print
text 1001010 in first page imediately and then receive the second data 1011111 and print in second page imediately and receive the next data and print. Please show me ( by use startdoc(), startpage() , endpage(), enddoc())
Thank you
|
|
|
|
|
I'd like to remove the CTabCtrl from a property sheet. Currently, I make it not visible, but I need to determine the size of the CTabCtrl in the property sheet to adjust the property pages accordingly. Otherwise, there's ugly space around it.
FYI: I'm using this approach as I use the property pages in a normal property sheet at times in addition to a "netscape'ish" property sheet.
|
|
|
|
|
If you already have a pointer to the tab control (possibly with GetTabControl ), GetWindowRect should return its dimensions. Then you can displace the remaining controls upwards in the OnInitDialog of the sheet just like this:
CWnd *pWnd=GetWindow(GW_CHILD);
while(pWnd!=NULL){
CRect rect;
pWnd->GetWindowRect(rect);
rect.OffsetRect(0,-tabHeight);
ScreenToClient(rect);
pWnd->MoveWindow(rect,FALSE);
pWnd=pWnd->GetNextWindow();
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
I've been staring at this problem for hours and hours... what is wrong?!
This is what I do:
...snip...
CComModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_Lex, CLex)
END_OBJECT_MAP()
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID )
{
if (dwReason == DLL_PROCESS_ATTACH)
{
TCHAR pszLoader[MAX_PATH];
GetModuleFileName(NULL, pszLoader, MAX_PATH);
_tcslwr(pszLoader);
if (_tcsstr(pszLoader, _T("explorer.exe")))
return FALSE;
_Module.Init(ObjectMap, hInstance, &LIBID_LEXBHOLib);
DisableThreadLibraryCalls(hInstance);
}
else if (dwReason == DLL_PROCESS_DETACH)
_Module.Term();
return TRUE;
}
...snap...
I get this error:
---Configuration: LexBHO - Win32 Unicode Release MinDependency--------
Linking...
Creating library ReleaseUMinDependency/LexBHO.lib and object ReleaseUMinDependency/LexBHO.exp
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
ReleaseUMinDependency/LexBHO.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
LexBHO.dll - 2 error(s), 0 warning(s)
But when I comment these lines out...
...things are working just fine. What is wrong with _tcslwr? Because that's where the problems start...
Help is much appreciated,
/Tommy
|
|
|
|
|
Ummm... the configuration you have selected (MinDependency) does not link the C run-time library to save space on the final DLL. So, you cannot use any of the functions provided by this library (like vg. _tcslwr ). Either change the configuration or avoid calls to the C run-time library.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
No, that's not it, but thanks anyway... I have another project that builds with this piece in ReleaseMinSize. That's what's making this thing so strange! What else can make it behave like this?
/Tommy
|
|
|
|
|
(Another shot in the dark) Seems like LIBCRT thinks is being linked against a console program instead of a DLL. Check the /subsystem directive in the linker part of the project settings.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Under your project settings, make sure that you have chosen one of the "Using MFC" options.
(IE. "Using MFC in a shared .dll" or "Using MFC in a statically linked .dll")
|
|
|
|
|
No, it works with a project I have and there's no MFC at all. And there shouldn't be!
It must be something else!
Mail me and I'll send the project to anyone who wants it!
/T
|
|
|
|
|
I had the same problem :
- put an empty main funxion somewhere to keep the linker happy
- don't use LIBC funxions
- tell me if you find another solution
|
|
|
|
|
This is a famous one. It is cause by _ATL_MIN_CRT preprocessor definition. Look here[^] for details.
Vagif Abilov
MCP (Visual C++)
Oslo, Norway
If you're in a war, instead of throwing a hand grenade at the enemy, throw one of those small pumpkins. Maybe it'll make everyone think how stupid war is, and while they are thinking, you can throw a real grenade at them.
Jack Handey, Deep Thoughts
|
|
|
|
|
Hi. I have some fundamental questions about dialog box and property sheet. Most ultimately have to do with program design and memory management.
Dialog Box:
Is the following good program design?
-----
MyBox mBox;
if (mBox.DoModal == IDOK)
// Is it good program design to get data from a dialog box after it has been closed/distroyed?
DataType = mBox.GetData();
-----
Dialog Box & Property Sheet:
What do you think about declare all dialog box and/or property sheets as private data member rather than local data member?
In general, I want to make sure there is not memory leak with dealing with dialog box and/or property sheet and local data members.
Thanks,
Kuphryn
|
|
|
|
|
Question 1: It is not only good style, but also about the only reasonable way to retrieve data entered by the user into the dialog. Go ahead with this solution.
Question 2: I don't know how keeping these private will help you prevent memory leaks. Could you be more specific?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks.
If you declare a dialog box locally, what if the function goes out of stack? If it is local, you can create a new box and delete each box every time.
Again, I would like to make sure everything is safe and good program design.
Kuphryn
|
|
|
|
|
I'm still not very sure about what your question is, but in general you should prefer to declare variables locally rather than as member variables (unless there are compelling reasons not to do so).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Here is an example of the second questions.
-----
Class MyClass()
{
void TestFunc();
privete MyDialogBox *dBox;
}
void MyClass::TestFunc()
{
dBox = new MyDialogBox;
if (MyDialogBox->DoModal == IDOK)
...
delete dBox;
dBox = NULL;
}
-----
In the code above, MyDialogBox is created on the heap instead of being a local call.
Kuphryn
|
|
|
|
|
It is much better to do it this way:
class MyClass
{
void TestFunc();
};
void MyClass::TestFunc()
{
MyDialogBox dBox;
if (dBox.DoModal() == IDOK)
...
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks. Nicely explained.
Kuphryn
|
|
|
|
|
how to know info about sockets currently run in a PC?
the sockets are created by other apps.
info includes ports, addresses for both side of sockets.
is it possible?
thx
includeh10
|
|
|
|
|
one link http://www.sysinternals.com/ntw2k/source/tcpview.shtml
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
another one http://www.sysinternals.com/ntw2k/freeware/tdimon.shtml
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
thank u!
before i try, i want to know if it is only avaliable on NT and win2k?
a flower ...
includeh10
|
|
|
|
|
there's a version for win 95/98/Me also, check it out at www.sysinternals.com
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
i downloaded 20 (or all) zips from the company. they look very wanderful!
i will go through to find key code.
i think u use them before, u should be an expert about the stories.
thx again
2 flowers ...
includeh10
|
|
|
|