|
Different to my previous answer.
The MFC doc/view handles the printing using the following functions:
OnPreparePrinting()
OnBeginPrinting()
OnPrint() // by default this calls your views OnDraw()
OnEndPrinting()
In your OnPreparePrinting you need to setup the CPrintInfo structure with the number of pages you wish to print:
pInfo->SetMaxPage(5) ;
The MFC code will then call your OnPrint() function once per page. It will have done the calls to StartDoc() and StartPage/EndPage() for you. You will need to look in the pInfo->m_nPage member to see which page is being printed. From this info you can determine which data to print.
OnBeginPrinting and OnEndPrinting are only used if you need to configure the output DC etc for a special print operation.
Roger Allen
Sonork 100.10016
yet to be identified being from the planet Paltinmoriumbanfrettybooter
|
|
|
|
|
Look at the MSDN article "CView::OnFilePrint and Other Command Handlers". It has a flowchart of the CView printing architecture.
Jonathan Craig
www.mcw-tech.com
|
|
|
|
|
I need to know the inf file that is equivalent to ntprint.inf in NT and Win2000. I am in need of diff. printer info and their driver files.
Can any one tell me what is pconfigfile while installing printer driver programmatically(AddPrinterDriver). Can i use any default file for this parameter, if so what is it for Win98,2000,me,nt ?
Please advise ....
Thanks in advance.
Somu.l
|
|
|
|
|
Hello world! I am stuck. Any help is highly appreciated.
Here is the situation:
I have 3 dialog box in a tab setting. base dialog has a
tab control, one edit control, and 4 buttons (Ok,Cancel,
Show, Populate).
PageOne dialog has a text control, and PageTwo has one text
control. All I want is: if I press Show button which is on
the basePage dialog, I want to see contents of all text controls
(basePage, PageOne, PageTwo).
If I press Populate button, I want to populate all text controls
of three dialogs (basePage, PageOne, PageTwo).
If you need more clarification, please send me a mail.
Thank you in advance.
|
|
|
|
|
you should be able to use pDlg->GetDlgItem to get to those controls.
-c
Conscience is what hurts when everything else feels good.
Smaller Animals Software, Inc.
|
|
|
|
|
As a new in VC, how to use it?
|
|
|
|
|
CString strTemp;
CEdit* pText1 = (CEdit*)GetDlgItem(IDC_TEXTBOX1);
pText1->GetWindowText(strTemp); // put value in textbox into strTemp string
pText1->SetWindowText("text"); // put text into textbox
i think you then have to call: UpdateData(true);
for the boxes to update
-dz
|
|
|
|
|
Hello dz:
sorry this does not work, got Assertion fail or illegal operation.
Thanks,
|
|
|
|
|
I'm writing a program about voice communication by DirectPlay8,and I found it's difficult to access address by IP,There are two interfaces IDirectPlay8Address & IDirectPlay8AddressIP,but when I use IDirectPlay8Peer to connect to a server, I can only use the the IDirectPlay8Address,How could I pass the parmeter to IDirectPlay8Peer::Connect using IDirectPlay8AddressIP,because I will look up the IP address in a database,so I don't want the user to input a IP,I want to access to IDirectPlay8AddressIP by a string.
So I need your help, how can I use IDirectPlay8AddressIP for connection.
Thanks a lot,
|
|
|
|
|
Hi There!
I've just started writing a CWnd derrived custom control, but I want it by default to have the WS_EX_CLIENTEDGE style. I tried doing this routine...
void CFooCtrl::PreSubclassWindow()
{
CWnd::PreSubclassWindow();
ModifyStyleEx(0, WS_EX_CLIENTEDGE);
}
But for some reason it doesn't work properly. Don't worry, I have checked whether the function is being called or not, and it is. Also, I tried in the dialog resource editor putting the hex of WS_EX_CLIENTEDGE style in the code box for my custom control, and it did produce the desired result. But I would like to have the style hard-coded. Does anyone know why the ModifyStyleEx function seems to be having not effect?
Any Help is much appreciated.
With time we live, with money we spend!
Joel Holdsworth
|
|
|
|
|
Try moving the stuff to CFooCtrl::PreCreateWindow .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
Yeah, problem with PreCreateWindow is that for controls in a dialog, PreCreateWindow is never called. Probably somthing to do with the window being creatded before the point where CFooCtrl picks it up. Very irritating. But thanks for the advice...
With time we live, with money we spend!
Joel Holdsworth
|
|
|
|
|
There's another alternative, tough it involves a little work:- Load the dialog template
DLGTEMPLATE structure into memory with FindResource , LoadResource and all that stuff.
- Traverse the controls defined in the
DLGTEMPLATE object, setting the desired style for the appropriate controls. - Launch the dialog with
CDialog:InitModalIndirect .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Well if thats what you had in mind, its probably easier to use the resource editor. Its just that I wanted the control to be self contained.
With time we live, with money we spend!
Joel Holdsworth
|
|
|
|
|
I'm writing something like a Trojan horse programme in VC7(SDI based without document&view support). I want to hide it thoroughly so that even when people press Ctrl + Atl +Del in windows 98,they can't see it in the list of running programmes.
Better give me a smaple project because I am really new to writing such a programme.
modified 1-May-21 21:01pm.
|
|
|
|
|
Shengqian Ji wrote:
I'm writing something like a Trojan horse programme
Hehehe
And you really ask ?!!?!
Max.
|
|
|
|
|
Hi! Good russian guy will help you (it's me )
Your trouble is well known and easy to solve.
I haven't time to translate info from russian, and I'll paste it as is. It'2 articles: for 9.x and NT based.
Source: our russian forum FAQ http://www.sources.ru/cpp/faqs/faq_forum.shtml
And I saw example of hiding from three buttons on 9.x on Codeproject (also trojan), search it...
Here's info (russian text will be unreadable):
Как скрыть свое приложение от диспетчера задач
A: (Iliya)
Внимание! Не работает в семействе NT (2000, XP)
typedef DWORD (WINAPI *LPREGISTERSERVICEPROCESS) (DWORD, DWORD);
HINSTANCE h_i;
LPREGISTERSERVICEPROCESS lpRegProc;
h_i = LoadLibrary("KERNEL32.DLL");
if (h_i)
{
lpRegProc = (LPREGISTERSERVICEPROCESS)GetProcAddress(h_i, "RegisterServiceProcess");
if (lpRegProc)
{
lpRegProc(NULL, 1);
}
FreeLibrary(h_i);
}
Наверх
--------------------------------------------------------------------------------
Как скрыть свое приложение от ProcessViewer
A: (источник: xaker.ru) Сокрытие процессов в Win2000/NT Я довольно долго пытался сделать свою программу невидимой в Windows 2000. Максимум, что я смог найти в интернете - это то что основой любого диспетчера задач является функция NtQuerySystemInformation, ее описание, а также то, что обмануть эту функцию невозможно. Не знаю, почему так говорят, но обмануть ее можно и это очень просто. Вот, что мне удалось нарыть про эту функцию:
NTAPI Hook_NtQuerySystemInformation(
LONG type, // тип требуемой информации
PVOID SystemInformation, // указатель на буфер, в который вернется информация
LONG SystemInformationLength, // размер буфера в байтах
PLONG ReturnLength // сколько байт было возвращено или требуется
);
Как было указано, первый параметр отвечает за тип требуемой информации. Нас интересует только информация о процессах (type = 5). Далее работаем со следующими структурами:
typedef struct {
FILETIME ProcessorTime;
ULONG unk2, unk3;
FILETIME CreateTime;
ULONG unk6;
ULONG StartAddress;
ULONG ProcessID;
ULONG ThreadID;
ULONG CurrentPriority;
ULONG BasePriority;
ULONG ContextSwitchesPerSec;
ULONG ThreadState;
ULONG ThreadWaitReason;
ULONG unk15;
} SYSTEM_THREAD_INFORMATION;
typedef struct {
ULONG NextOffest; // следующий процесс
ULONG ThreadCount;
ULONG unk2, unk3, unk4, unk5, unk6, unk7;
FILETIME CreateTime;
FILETIME UserTime;
FILETIME KernelTime;
ULONG unk14;
WCHAR *pModuleName; /* unicode */
ULONG BasePriority;
ULONG ProcessID;
ULONG InheritedFromUniqueProcessID;
ULONG HandleCount;
ULONG unk20, unk21;
ULONG PeekVirtualSize;
ULONG VirtualSize;
ULONG PageFaultCountPerSec;
ULONG PeakWorkingSetSize;
ULONG WorkingSetSize;
ULONG PeekPagedPoolUsage;
ULONG PagedPoolUsage;
ULONG PeekNonPagedPoolUsage;
ULONG NonPagedPoolUsage;
ULONG unk31; /* PagefileUsage ? */
ULONG PeakPagefileUsage;
ULONG unk33; /* PrivateBytes ? */
SYSTEM_THREAD_INFORMATION ThreadInfos[1]; // потоки данного процесса
} SYSTEM_PROCESS_INFORMATION;
После вызова функции, если не произошло ошибки, первым элементом буфера окажется структура SYSTEM_PROCESS_INFORMATION, описывающая отдельный процесс. Первым членом этой структуры будет смещение, указывающее на следующий процесс или NULL, если это последний процесс в списке. Теперь осталось только перехватить все вызовы этой функции и немного поменять смещения, чтобы вызывающая функцию программа перепрыгнула через наш процесс. Наш это процесс или не наш определяем по идентификатору процесса progProcessId, определяемому при запуске программы. Теперь, после перехвата функции NtQuerySystemInformation (все детали перехвата очень подробно описаны в книге Рихтера или смотрите исходники), вместо оригинальной функции сначала вызывается наша:
NTAPI Hook_NtQuerySystemInformation(
LONG type, // тип информации
PVOID SystemInformation, // указатель на буфер
LONG SystemInformationLength, // размер буфера в байтах
PLONG ReturnLength // указатель на 32-битное число
)
{
SYSTEM_PROCESS_INFORMATION *pinfo, *pinfo_last;
// вызываем оригинальную функцию
((PFNNtQuerySystemInformation)(PROC) g_NtQuerySystemInformation)
(type, SystemInformation, SystemInformationLength, ReturnLength);
// если получается информация о процессах
if(type == 5)
{
if(SystemInformationLength > 20000)
{
pinfo = (SYSTEM_PROCESS_INFORMATION*)SystemInformation;
for(;;)
{
// если идентификатор процесса равен идентификатору нашего процесса
if(pinfo->ProcessID == progProcessId)
{
// если наш процесс последний в списке
if(pinfo->NextOffest == 0)
{ // предпоследний процесс теперь стал последним, а наш исчез
pinfo_last->NextOffest = 0;
}
else
{ // или прыгаем через наш процесс
pinfo_last->NextOffest += pinfo->NextOffest;
}
}
if(pinfo->NextOffest == 0) break;
// предудущий процесс теперь равен текущему
pinfo_last = pinfo;
// переходим к следующему процессу
pinfo = (SYSTEM_PROCESS_INFORMATION*)((char *)pinfo + pinfo->NextOffest);
}
}
}
}
Теперь любая вызывающая программа при просмотре возвращенного буфера будет прыгать через наш процесс. Вот и все. В исходниках находится программа, демонстрирующая все вышеизложенное. Сначала компилируем библиотеку, затем программу. Конечно для полного сокрытия программы в WINDOWS 2000 этого маловато, стоит также перехватить функции просмотра загруженных библиотек, FindFirsFile, FindNextFile, подставляя вместо нужного файла "..". Если есть какие-то замечания, предложения или что-то еще, то пишите: researcher@land.ru.
|
|
|
|
|
Hi
I was wondering if some one could help me with the sort function of CList control. My first column consists of numbers to be added by the user. I need the numbers to be sorted but If I make the member variable integers I am unable to use the InsertItem function so am I restricted to CStrings?
|
|
|
|
|
Catherine... were you referring to sorting a CList or CListCtrl?
|
|
|
|
|
I have an Edit control where the user enters a number. When the user presses
return the number gets added to a CListCtrl. The edit control's member variable is a CString. I want the numbers in the ListCtrl to be sorted numerically, however by selecting ascending sort on the ListCtrl the nubers appear for example in this order:
1
2
22
3
4
|
|
|
|
|
it sounds like you might need to convert your CStrings to ints (using the atoi()) during your sort function, something similar to:
int n1 = atoi((const char*) pListCtrl->GetItemText(lParam1, 0));
int n2 = atoi((const char*) pListCtrl->GetItemText(lParam2, 0));
then doing the comparision on the ints.
|
|
|
|
|
Just wondering if any of you clever peeps out there
could help me in creating my first c++ dll.
I just need and example of a dll containing a function
that takes one int, multiplies it by two and returns
the answer.
The main bit i'm stuggling to find out is how you make
this function accessable so it can be called externally;
I managed to find out how to do it in delphi e.g.
library Sample;
uses
SysUtils,
Classes;
{$R *.RES}
function MultiplyByTwo(X: integer): integer; cdecl; export;
begin
MultiplyByTwo := X * 2;
end;
exports
MultiplyByTwo;
begin
end.
but as i don't have access to delphi, it's not much help.
Any help would be greatly appreciated.
|
|
|
|
|
Yeah, that delphi stuff is pretty well useless...
Have a look at the DLL sction of codeproject. It should help you out.
With time we live, with money we spend!
Joel Holdsworth
|
|
|
|
|
Thanks Joel,
What would be really useful was if you could, knock me up an example
that mirror's the functionality of the delphi example.
Just to explain why i need this, we use an automated testing tool
called QARun, it's good for it's job but the functions it can perform
are a bit limited. One thing you can do is use call functions in external
dll's.
Once i've got the basic's of how to structure and compile the dll i can usually
find the code for what i need to do in the msdn library or on the web.
It's partly a learning exercise for me, but it will also come in handy when
i need to to something that qarun can't do directly (just about anything do to
with the registry for example.)
If you could help it would be much appreciated.
Simon
|
|
|
|
|
Any body can give me a hint? I have two projects, one is dialog based, one is SDI based. I have draw up all the resources for the dialog based project, and I want to copy all of them to my SDI based project. Is there any easy way to do it?
Thank you very much in advance!
|
|
|
|
|