|
I believe those messages are being captured when you derive a class from another class. So would the real difference be that using the derivation method you are able to add your own functions and implementation rather than just capture messages using the SubClassWindow function?
|
|
|
|
|
Hi,
I'm trying to write a control that contains lots of child controls, and allows you to scroll them up and down. This would be very much like how CFormView works, except based on CWnd, not on CView. Can anyone give me a rough outline of the mechanism which CScrollView uses to draw the child controls at different locations as you pan around without moving those child windows?
Joel Holdsworth
|
|
|
|
|
|
Thanks man. That's a massive help!
Joel Holdsworth
|
|
|
|
|
I was designing the database part of a module to be developed in C++. Let me explain the scenario.
I have to access 4 different databases which are not related in any way. So I created 4 classes that holds the business logic to manipulte each of the databases. Then I thought of creating a database access class for each of the dbs to implement the data access code using ADO, so that the business logic class can call the public functions of these classes to get things done. Then I found that the Connection object is common for all the 4 classes, also there are a few methods that are common, like the OpenDatabase, CloseDatabase, IsOpen, GetProviderError etc etc. So I created a base class for that.
Now I have two options, I can either derive the 4 data access classes from the base, or I can contain a member of the base in each one of the 4. Remember, I need all the functionalities implemented in the base class as such in all the 4 classes that implement the business logic. It was found that most people say that we must try to go for weaker coupling if possible, that way I must go for containment. But then I will have to write stub functions to call the base object's function, which is an overhead.
I would appreciate it if somebody can give me an advice in this regard.
Thanks in advance,
Sylesh.
|
|
|
|
|
Hello,
You can do different things depending on your needs. If your base class is likely too change a lot and your system is very large (it takes a lot of time to compile and link), I definitly would go for the private data member.
From a logical design point of view, the most obvious thing to do is to derive your specialized classes from the base class. This way, your small accessor functions can be inlined better and you don't have to do much additional allocations, since that adds a lot of overhead.
Remember this: containment comes at a price. Overhead is the price to pay. How much you contain depends on each scenario... for example, a widely used class should contain all the implementation details at the cost of more runtime overhead. A not so widely used class doesn't need to contain all the details.. etc..
Hope this helps
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
I search to implement versioning support in MFC applications using ActiveX. I've got some ideas, but I wonder if I'm not re-inventing the wheel. So if somebody has any hint about embedded ActiveX versioning support, I would be grateful, TIA
|
|
|
|
|
Surely you are not talking about VERSIONINFO.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Nope, it wasn't that one . I'm trying to use the "persistence support" mechanism from Activex serialization, which should manage versioning.. I hope
Thanks for your tip anyway, I might need it in the end
|
|
|
|
|
Hi,
I'm writing an app which has a transparent dialog SetLayeredWindowAttributes But I need a transparent dialog witout transparent Child Windows, I mean not a transparent button, text, combo, ... .
Is there any way?idea?
Thank you in advanced.
|
|
|
|
|
hello,
I have bitmaps created on my dialog box.When my mouse will go on on each bitmap i want to dispaly some text.Will somebody guide me how to use CToolTipCtrl class.In that there is AddTool () function,but i am getting error while passing handler or id to bitmap.The function doesnt take it.hwta is the solution?
please help
thanks in advance
|
|
|
|
|
I'm not sure if there is a way to put a tooltip for a bitmap, once I wanted to do this, I finally used the bounding rectangle instead of the bitmap itself!!! it might help.
myTooltipCtrl.AddTool(this/*My Dialog pointer*/,_T("tip text"),rect/*Bounding rectangle*/, 1);
|
|
|
|
|
hello,
Can you please expalin what is ounding rectangle?I am placing my bitmap in a picture control.So in place of first parameter 'this' in AddTool() function shall i give id of pictue control.
please help
thanks in advance
|
|
|
|
|
Hi,
First of all, It's NOT 'ounding' as you said ;) Its Bounding.
I had not enough time to read (MSDN), this is all my memories!!, so there might be some problems,Please first read (MSDN) carefully for all functions here, before using them.
Do the following:
1-Activate 'Notify' on 'Style' tab of your 'picture control' (In Resource editor)
2-On your InitDialog :
// No tooltip created
m_toolTip.m_hWnd = NULL;
// Create ToolTip control
m_toolTip.Create(this, TTS_ALWAYSTIP );
// Enable multiline
m_toolTip.SendMessage(TTM_SETMAXTIPWIDTH, 0, 400);
CRect rc;<br />
GetDlgItem(IDC_PIC)->GetClientRect(rc);<br />
m_toolTip.AddTool(GetDlgItem(IDC_PIC),"ToolTip",rc,IDC_PIC);
//Time to activate tooltip
m_toolTip.Activate(TRUE);
3-Using your ClassWizard, Add a message handler for: 'PreTranslateMessage'
4-In the function :
... PreTranslateMessage(MSG* pMsg)
{
m_toolTip.RelayEvent(pMsg);
}
Hope this will help
|
|
|
|
|
This can be done automatically using Visual Studio. If you look at the Properties for any of the "standard" toolbar buttons generated for a blank project (SDI or MDI), check out the "Prompt" line at the very bottom of this dialog. There will be 2 strings, separated by a newline character. The first string will be displayed in the status bar, while the second will be used as the popup tooltip text (what you're looking for).
For example, the standard ID_FILE_SAVE button's Prompt string reads "Save the active document\nSave". "Save the active document" is displayed on the status bar while hovering over this button, while "Save" is displayed as the tooltip text while hovering.
Note that this prompt string also affects any menu items that use the same ID. Only the first of the Prompt strings is used, however, to fill in the status bar.
To get the tooltips for your buttons, just edit the Prompt string under the button's Properties.
Hope this helps.
Bob Ciora
|
|
|
|
|
I should mention also that this Prompt string information is also saved to your application's String Table under the ID of the command itself.
Bob Ciora
|
|
|
|
|
Dear Mr. Bob
Hi,
Your answer is elegant but not for his question perhaps, he asked:
I have bitmaps created on my dialog box....
Will somebody guide me how to use CToolTipCtrl [NOT CToolbar] class.In that there is AddTool () ...
|
|
|
|
|
Hello,
I have designed a simple device driver that export with the help of IOCTL's some variables.
I made a win 32 api that load the driver, and looks up an event in the driver.
The event works just fine it signales everytime it should, but whenever I call DeviceIoControl and then I call GetLastError(), FormatMessage() I see that the error mesage is always the same: "The parameter is incorrect" . I don't know what parameter, bacause I have checked all parameters and they are all correct.
Maybe I have missed something before calling DeviceIoControl function.
These are the steps I considered:
OpenSCManager();
CreateService(); if service already running OpenService()
StartService();
CreateFile(); //get the driver's handle
OpenEvent(); //get the event handle created by the driver;
DeviceIoControl(); //and I get the error
and then it is not important because it is not related to;
Please tell me what can be wrong. the IOCTL -> CTLCODE are the same in the driver as in the aplication.
I don't see what can I miss.
If you want I can give you a code snippet.
Thanks
gabby
|
|
|
|
|
How are you calling DeviceIoControl() ?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
int st=DeviceIoControl(hDrv,
IOCTL_PROCOBSRV_ACTIVATE_MONITORING,
&activateInfo,
sizeof(activateInfo),
NULL,
0,
&ret,
NULL
);
gabby
|
|
|
|
|
Is this article of any help? It uses that same control code.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
hope this is good
<br />
#include "stdafx.h"<br />
#include <windows.h><br />
#include <stdio.h><br />
#include <psapi.h><br />
#include <conio.h><br />
<br />
#pragma comment (lib,"psapi.lib")<br />
LPCTSTR GetDriverFromFilePath(LPTSTR FilePath, LPTSTR DriverName);<br />
LPCTSTR ErrorMessage(DWORD ErrorId);<br />
typedef struct _ActivateInfo<br />
{<br />
BOOLEAN bActivate;<br />
} ACTIVATE_INFO, *PACTIVATE_INFO;<br />
<br />
typedef struct _CallbackInfo<br />
{<br />
HANDLE hParentId;<br />
HANDLE hProcessId;<br />
BOOLEAN bCreate;<br />
}CALLBACK_INFO, *PCALLBACK_INFO;<br />
<br />
DWORD WINAPI Opreste(LPVOID pParam);<br />
<br />
HANDLE kmev;<br />
bool out;<br />
#define FILE_DEVICE_UNKNOWN 0x00000022<br />
#define IOCTL_UNKNOWN_BASE FILE_DEVICE_UNKNOWN<br />
#define IOCTL_PROCOBSRV_ACTIVATE_MONITORING \<br />
CTL_CODE(IOCTL_UNKNOWN_BASE, 0x0800, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)<br />
#define IOCTL_PROCOBSRV_GET_PROCINFO \<br />
CTL_CODE(IOCTL_UNKNOWN_BASE, 0x0801, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)<br />
<br />
<br />
int _cdecl main(void)<br />
{<br />
<br />
<br />
<br />
WIN32_FIND_DATA fd;<br />
<br />
SC_HANDLE hSCManager;<br />
SC_HANDLE hService;<br />
<br />
<br />
<br />
FindFirstFile("*.sys",&fd);<br />
char path[1024];<br />
GetModuleFileName(0,path,sizeof(path));<br />
MessageBox(0,ErrorMessage(GetLastError()),"GetModuleFileName",MB_ICONINFORMATION);<br />
char DriverName[1024];<br />
strcpy(DriverName,GetDriverFromFilePath(path,fd.cFileName));<br />
<br />
hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);<br />
MessageBox(0,ErrorMessage(GetLastError()),"OpenSCManager",MB_ICONINFORMATION);<br />
printf("Load Driver\n");<br />
<br />
if(hSCManager!=NULL)<br />
{<br />
<br />
printf("Create Service\n");<br />
<br />
<br />
hService = CreateService(hSCManager,fd.cFileName,fd.cFileName,SERVICE_ALL_ACCESS,SERVICE_KERNEL_DRIVER,SERVICE_DEMAND_START,SERVICE_ERROR_NORMAL,DriverName,NULL,NULL,NULL,NULL,NULL);<br />
MessageBox(0,ErrorMessage(GetLastError()),"CreateService",MB_ICONINFORMATION);<br />
<br />
if (hService==NULL) hService=OpenService(hSCManager, fd.cFileName,SERVICE_ALL_ACCESS);<br />
MessageBox(0,ErrorMessage(GetLastError()),"OpenService",MB_ICONINFORMATION);<br />
printf("Start Service\n");<br />
<br />
if(StartService(hService, 0, NULL)==0)<br />
{<br />
MessageBox(0,ErrorMessage(GetLastError()),"Start Service",MB_ICONINFORMATION);<br />
DeleteService(hService);<br />
CloseServiceHandle(hService);<br />
<br />
}<br />
else<br />
{<br />
<br />
SERVICE_STATUS ss;<br />
while (1)<br />
{<br />
QueryServiceStatus(hService,&ss);<br />
if (ss.dwCurrentState!=SERVICE_RUNNING)<br />
{<br />
if (ss.dwWaitHint<1000) Sleep(1000);<br />
else <br />
if (ss.dwWaitHint>10000) Sleep(10000);<br />
else Sleep(ss.dwWaitHint);<br />
<br />
}<br />
else<br />
goto out;<br />
<br />
}<br />
<br />
<br />
<br />
}<br />
}<br />
<br />
out:<br />
<br />
MessageBox(NULL,"Service running","",MB_OK);<br />
<br />
<br />
DWORD ret;<br />
HANDLE hDrv;<br />
char pth[1024];<br />
char DrvPath[1024];<br />
<br />
GetModuleFileName(GetModuleHandle(0),pth,sizeof(pth));<br />
<br />
strcpy(DrvPath,GetDriverFromFilePath(pth,fd.cFileName));<br />
MessageBox(0,DrvPath,"",MB_OK);<br />
<br />
<br />
hDrv=CreateFile(DrvPath,<br />
GENERIC_READ | GENERIC_WRITE,<br />
FILE_SHARE_READ | FILE_SHARE_WRITE,<br />
0,<br />
OPEN_EXISTING,<br />
FILE_FLAG_OVERLAPPED,<br />
0);<br />
MessageBox(0,ErrorMessage(GetLastError()),"CreateFile",MB_ICONINFORMATION);<br />
<br />
<br />
out=false;<br />
CALLBACK_INFO call;<br />
ACTIVATE_INFO activateInfo;<br />
activateInfo.bActivate=TRUE;<br />
bool active=false;<br />
CreateThread(0,0,Opreste,0,0,0);<br />
<br />
<br />
kmev=OpenEvent(SYNCHRONIZE,FALSE,"ProcObsrvProcessEvent");<br />
MessageBox(0,ErrorMessage(GetLastError()),"OpenEvent kmev",MB_ICONINFORMATION);<br />
int st=DeviceIoControl(hDrv,<br />
IOCTL_PROCOBSRV_ACTIVATE_MONITORING,<br />
&activateInfo,<br />
sizeof(activateInfo),<br />
NULL,<br />
0,<br />
&ret,<br />
NULL<br />
);<br />
<br />
MessageBox(0,ErrorMessage(GetLastError()),"DeviceIoControl",MB_ICONINFORMATION);<br />
<br />
<br />
<br />
<br />
<br />
while(!kbhit())<br />
{<br />
call.hProcessId=NULL;<br />
if (kmev==0) MessageBox(0,"Wait Failed: kmev==0","",MB_OK);<br />
<br />
if(WaitForSingleObject(kmev,INFINITE)==WAIT_FAILED)<br />
MessageBox(0,"Wait Failed=Wait","",MB_OK);<br />
OVERLAPPED ov = { 0 };<br />
ov.hEvent=CreateEvent(0,1,0,0);<br />
<br />
int stat;<br />
stat=DeviceIoControl(hDrv,<br />
IOCTL_PROCOBSRV_GET_PROCINFO,<br />
0,<br />
0,<br />
&call,<br />
sizeof(call),<br />
&ret,<br />
0);<br />
MessageBox(0,ErrorMessage(GetLastError()),"DeviceIoControl",MB_ICONINFORMATION);<br />
<br />
<br />
<br />
<br />
<br />
if (call.hProcessId!=NULL)<br />
{<br />
DWORD need;<br />
HMODULE mods[1000];<br />
char nume[1024];<br />
<br />
EnumProcessModules(OpenProcess(PROCESS_ALL_ACCESS,FALSE,(DWORD)call.hProcessId),mods,sizeof(mods),&need);<br />
GetModuleFileName(mods[0],nume,sizeof(nume));<br />
if(call.bCreate==TRUE)<br />
MessageBox(NULL,nume,"Process Created",MB_OK);<br />
else<br />
MessageBox(NULL,nume,"Process Terminated",MB_OK);<br />
}<br />
CloseHandle(ov.hEvent);<br />
Sleep(100);<br />
}<br />
<br />
getch();<br />
printf("%s","Unloading driver");<br />
ACTIVATE_INFO ac;<br />
ac.bActivate=FALSE;<br />
DeviceIoControl(hDrv,IOCTL_PROCOBSRV_ACTIVATE_MONITORING,&ac,sizeof(ac),NULL, 0,&ret,NULL);<br />
MessageBox(0,ErrorMessage(GetLastError()),"DeviceIoControl",MB_ICONINFORMATION);<br />
ControlService(hService,SERVICE_CONTROL_STOP,0);<br />
DeleteService(hService);<br />
<br />
<br />
return 0;<br />
}<br />
<br />
DWORD WINAPI Opreste(LPVOID pParam)<br />
{<br />
bool x;<br />
x=false;<br />
while(x==false)<br />
{<br />
if(GetAsyncKeyState(VK_ESCAPE)<0)<br />
{<br />
<br />
x=true;<br />
out=true;<br />
}<br />
Sleep(1);<br />
}<br />
<br />
_exit(0);<br />
ExitThread(0);<br />
return 0;<br />
}<br />
<br />
<br />
<br />
LPCTSTR GetDriverFromFilePath(LPTSTR FilePath, LPTSTR DriverName)<br />
{<br />
char file[1024];<br />
char file1[1024];<br />
strcpy(file,_strrev(FilePath));<br />
char slesh[2]={'\\','\0'};<br />
<br />
<br />
for (int i=0; i<=strlen(file); i++)<br />
{<br />
char fl[2]={'\0','\0'};<br />
<br />
fl[0]=file[i];<br />
fl[1]='\0';<br />
if (strcmp(fl,slesh)==0) break;<br />
<br />
}<br />
<br />
strcpy(file1,_strrev(file));<br />
file1[strlen(file1)-i]='\0';<br />
strcat(file1,DriverName);<br />
<br />
return file1;<br />
}<br />
LPCTSTR ErrorMessage(DWORD ErrorId)<br />
{<br />
<br />
LPVOID lpMsgBuf;<br />
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |FORMAT_MESSAGE_FROM_SYSTEM |FORMAT_MESSAGE_IGNORE_INSERTS,<br />
NULL,<br />
ErrorId,<br />
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),<br />
(LPTSTR) &lpMsgBuf,<br />
0,<br />
NULL<br />
);<br />
<br />
return LPCTSTR(lpMsgBuf);<br />
<br />
}<br />
gabby
|
|
|
|
|
Hi all,
I am writing a http server and client in order to pass binary data(image) from client to server. And can I transmit the binary data in binary format in the http protocol as payload, without doing base64 encoding for the binary data ?
Thanks
|
|
|
|
|
Hi,
Does anyone know how to change the colour of the HotItem-colour,
my problem is that the item set hot at the moment is dark blue and is not easily noticed next to the other items that are black. I would rather set it yellow or something instead.
Thanks in advance,
Janette
|
|
|
|
|
In my project i have inserted a WebBrowser ActiveX Control.
I want to supress the FileDownload dialog...
|
|
|
|
|