|
Try the below code.
CRect ClientRect;<br />
GetClientRect( &ClientRect );<br />
CRect LastItemRect;<br />
int nLastitem = GetHeaderCtrl()->GetItemCount() - 1;<br />
GetHeaderCtrl()->GetItemRect( nLastitem , &LastItemRect );<br />
int nNewLength = ClientRect.right - LastItemRect.left ;<br />
SetColumnWidth( nLastitem , nNewLength );
nave
|
|
|
|
|
thank you,
can you please reproduce this probelm by using
1> press window key + e
2> go to details view of folder
now see last column here in list.
can we get last column by using getheaderctrl() fn,
now i have to re distribute this space into all column at runtime .
thanks
rakesh
|
|
|
|
|
if you want to equally distribute the column width do as follows..
CRect ClientRect;
GetClientRect( &ClientRect );
CRect LastItemRect;
int nCount = GetHeaderCtrl()->GetItemCount();
int nWidth = ClientRect.Width()/nCount;
for( int nIdx = 0;nIdx < ncount; nIdx++)
{
SetColumnWidth( nIdx , nWidth );
}
nave
|
|
|
|
|
|
The list will do this for you. Call SetColumnWidth() on the last column and use the LVSCW_AUTOSIZE_USEHEADER flag.
|
|
|
|
|
Hi all,
I want to create a new class derived from CTime.
<br />
class XTime : public CTime <br />
{<br />
public:<br />
XTime();<br />
virtual ~XTime();<br />
<br />
};<br />
then I create a new object
XTime m_Date;
and then I want to initialize my object:
m_Date = NULL;
there is an error when compiling. When I create my object from a normal CTime, everything works.
As far as I learned C++, I can derive a new class and it inherits everything from the base class. But why can't I initialize it? It seems, that the = operator is not working.
Any help?
Juergen
|
|
|
|
|
This is because CTime have a contrcvtor of type CTime(time_t time);
So in the derived class also declare a constructor which accepts a time_t object and simply pass that object to base class.
class XTime : public CTime <br />
{<br />
public:<br />
XTime();<br />
virtual ~XTime();<br />
<br />
XTime( time_t t ):CTime(t)<br />
{<br />
}<br />
<br />
<br />
};
nave
|
|
|
|
|
Ahh, that helped a lot.
Now I have to find a way to inherit the = operator.
Thanks a lot
Juergen
|
|
|
|
|
e-DJ wrote: Now I have to find a way to inherit the = operator.
here it is
class XTime : public CTime
{
public:
XTime();
virtual ~XTime();
XTime( time_t t ):CTime(t)
{
}
const XTime& operator=(time_t t)
{
CTime::operator =( t );
return *this;
}
};
nave
|
|
|
|
|
Aargh,
I use CTime in my application all the time with almost all operators and constructors. When I have to reimplement them all, where is the use in object oriented design. Since I don't want to change these. All I wantetd to change was the behavior of the .Format-Class Member.
I canceled this and will redesign my application.
Juergen
|
|
|
|
|
e-DJ wrote: It seems, that the = operator is not working.
operator = is not inherited. You should redefine it in your derived class.
|
|
|
|
|
Since now, I have not been working with operators. So how should my operator= be defined?
Juergen
|
|
|
|
|
e-DJ wrote: I want to create a new class derived from CTime.
Be careful not to get caught in the "is a" vs. "has a" trap.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi all.
I write win service and I have simple code:
<br />
void main(void)<br />
{<br />
SERVICE_TABLE_ENTRY DispatcherTable[] =<br />
{<br />
{<br />
(LPWSTR)MYServiceName,<br />
(LPSERVICE_MAIN_FUNCTION)ServiceMain<br />
},<br />
{<br />
NULL,<br />
NULL<br />
}<br />
};<br />
<br />
printf("Sample of simple service\n(C) D. Bagaturia, 2007, Email: dato_baga@mail.ru\n");<br />
<br />
<br />
if(!StartServiceCtrlDispatcher(DispatcherTable))<br />
{<br />
CloseHandle(hMutex);<br />
return;<br />
}<br />
<br />
}<br />
Problem is that: Wen 'ServiceMain' function ends control go to main() function, and wen main() ends program ends, sow I get thet my service works less than second.
I try to write:
<br />
void main(void)<br />
{<br />
HANDEL hThread;<br />
SERVICE_TABLE_ENTRY DispatcherTable[] =<br />
{<br />
{<br />
(LPWSTR)MYServiceName,<br />
(LPSERVICE_MAIN_FUNCTION)ServiceMain<br />
},<br />
{<br />
NULL,<br />
NULL<br />
}<br />
};<br />
<br />
printf("Sample of simple service\n(C) D. Bagaturia, 2007, Email: dato_baga@mail.ru\n");<br />
<br />
<br />
if(!StartServiceCtrlDispatcher(DispatcherTable))<br />
{<br />
CloseHandle(hMutex);<br />
return;<br />
}<br />
<br />
do{<br />
GetExitCodeThread(hThread,
lpExitCode);<br />
if(*lpExitCode == STILL_ACTIVE)<br />
Sleep(150);<br />
else<br />
break;<br />
<br />
}while(1);<br />
<br />
}<br />
But in this time I get runtime error.
Wen I try to start or stop my service in ServiceManager, I get error message.
I know thet I blocked the service in case two, but I need this service more then 1 second.
Sow I have:
case 1: service runs less 1 second.
case 2: service runs but, it is blocked.
I know that I made som mistake, but whot?
|
|
|
|
|
Your original main was correct. The loop should be in the ServiceMain routine. Before entering the loop, your ServiceMain routine should call RegisterServiceCtrlHandlerEx to establish a callback routine for the SCM to call when the OS needs to change the state of your service. Typically, the ControlHandler sets some kind of signal, like an event. The loop in the ServiceMain then periodically checks for that signal.
Judy
|
|
|
|
|
Thanks all for reply, it help me.
I test my service on 'windows service 1998' and I think that my service is 'Ok', but it dont run on this operation system.
I have some manager exe file for this service and I think this exe have problem to 'operation system', sow wen I start service by this manager exe I get error code that service cant start.
Can this be true?
Tahnks again for your reply.
|
|
|
|
|
I'm asuming when you say "windows service 1998" that you are refering to Windows 98. I've never even tried to use one under anything earlier the NT4. Also, the MSDN documentation for the service control functions (both those from within the service like StartServiceCtrlDispatcher and those used by the calling program such as StartService) states they are NT4 or higher also. Looks like 98 is out.
Services are not the easiest things to debug. You just can't "start" them in the debugger. I typically put an ASSERT(false) in the very beginning of my _main function to force an exception and then begin debugging from there, putting break points into my ServiceMain function.
From your earlier post, it looks like you haven't done much with services before. Here is a basic outline of what one should look like. Note that I've omitted the error checking.
SERVICE_STATUS_HANDLE glb_sshStatusHandle;
SERVICE_STATUS glb_ssStatus;
VOID WINAPI MMServiceMain (DWORD dwArgc, LPTSTR *lpszArgv);
DWORD WINAPI MMServiceControl (DWORD dwCtrlCode, DWORD dwEventType,
LPVOID lpEventData, LPVOID lpContext);
int _tmain (int argc, TCHAR* argv[], TCHAR* envp[])
{
SERVICE_TABLE_ENTRY dispatchTable[] = {
{ "MMService", (LPSERVICE_MAIN_FUNCTION) MMServiceMain},
{ NULL, NULL} };
StartServiceCtrlDispatcher (dispatchTable);
glb_ssStatus.dwCheckPoint = 0;
return 0;
}
void WINAPI MMServiceMain (DWORD dwArgc, LPTSTR *lpszArgv)
{
glb_ssStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
glb_ssStatus.dwServiceSpecificExitCode = 0;
glb_sshStatusHandle = RegisterServiceCtrlHandlerEx (
"MMService", MMServiceControl, NULL);
glb_ssStatus.dwControlsAccepted = 0;
glb_ssStatus.dwCurrentState = SERVICE_START_PENDING;
glb_ssStatus.dwWin32ExitCode = NO_ERROR;
glb_ssStatus.dwWaitHint = 5000;
glb_ssStatus.dwCheckPoint = glb_ssStatus.dwCheckPoint++;
SetServiceStatus (glb_sshStatusHandle, &glb_ssStatus);
if (!Init ()) {
glb_ssStatus.dwCurrentState = SERVICE_STOPPED;
glb_ssStatus.dwWin32ExitCode = NO_ERROR;
glb_ssStatus.dwWaitHint = 0;
glb_ssStatus.dwCheckPoint = glb_ssStatus.dwCheckPoint++;
SetServiceStatus (glb_sshStatusHandle, &glb_ssStatus);
return;
}
glb_ssStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
glb_ssStatus.dwCurrentState = SERVICE_RUNNING;
glb_ssStatus.dwWin32ExitCode = NO_ERROR;
glb_ssStatus.dwWaitHint = 0;
glb_ssStatus.dwCheckPoint = glb_ssStatus.dwCheckPoint++;
SetServiceStatus (glb_sshStatusHandle, &glb_ssStatus);
Run ();
glb_ssStatus.dwCurrentState = SERVICE_STOPPED;
glb_ssStatus.dwWin32ExitCode = NO_ERROR;
glb_ssStatus.dwWaitHint = 0;
glb_ssStatus.dwCheckPoint = glb_ssStatus.dwCheckPoint++;
SetServiceStatus (glb_sshStatusHandle, &glb_ssStatus);
return;
}
DWORD WINAPI MMServiceControl (DWORD dwCtrlCode, DWORD dwEventType,
LPVOID lpEventData, LPVOID lpContext)
{
if (dwCtrlCode == SERVICE_CONTROL_STOP) {
glb_ssStatus.dwCurrentState = SERVICE_STOP_PENDING;
glb_ssStatus.dwWin32ExitCode = NO_ERROR;
glb_ssStatus.dwWaitHint = 0;
glb_ssStatus.dwCheckPoint = glb_ssStatus.dwCheckPoint++;
SetServiceStatus (glb_sshStatusHandle, &glb_ssStatus);
SetEvent (hStopEvent);
return NO_ERROR;
}
else
return ERROR_CALL_NOT_IMPLEMENTED;
}
bool Init ()
{
hStopEvent = CreateEvent (NULL, TRUE, FALSE, NULL);
return true;
}
void Run ()
{
while (WaitForSingleObject (hStopEvent, 1) != WAIT_OBJECT_0)
{
}
CloseHandle (hStopEvent);
return;
}
|
|
|
|
|
Thanks for your help.
|
|
|
|
|
Dear all.
I install one driver that has one thread in it.
But the priority of driver is low and when I use user program which uses that driver capabilities , I find that because of low priority of driver, my program doesn't work properly.
I dont have the source code of drivers.
But I want to set my driver priority to real time .
Is it possible to do this.
If it is possible please let me know how I can do it.
I use following functions to install driver.
to install driver I use :
hService = ::CreateService(hSCManager, "Webcam",
"Webcam", SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER,
SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, PathOfDriver,
NULL, NULL, NULL, NULL, NULL)))
to start driver I use :
2. hService=OpenService(hscManager,NT_DRIVER_FILE,SERVICE_START)
in application which uses th capabilities of driver I use following functions to make programs priority high.
SetPriorityClass()
SetThreadPriority()
|
|
|
|
|
hi
I have enumed all computer in my workgroup by API function NetServerEnum,but i can't enum more about another workgroup's computer.
so my question is how can i get all computer in lan.
my code is here
CString strTemp;
CString strname="";
LPSERVER_INFO_101 pBuf = NULL;
DWORD dwLevel = 101;
DWORD dwPrefMaxLen = MAX_PREFERRED_LENGTH;
DWORD dwEntriesRead = 0;
DWORD dwTotalEntries = 0;
DWORD dwTotalCount = 0;
DWORD dwServerType = SV_TYPE_DOMAIN_ENUM ;
DWORD dwResumeHandle = 0;
NET_API_STATUS nStatus;
unsigned short * pszServerName = NULL;
char szOut[2048];
// DWORD i;
// DWORD dwServerType = SV_TYPE_DOMAIN_ENUM; // all servers
// LPSERVER_INFO_101 pTmpBuf;
// Call the NetServerEnum function to retrieve information
// for all servers, specifying information level 101.
nStatus = NetServerEnum(pszServerName,
dwLevel,
(LPBYTE *) &pBuf,
dwPrefMaxLen,
&dwEntriesRead,
&dwTotalEntries,
dwServerType,
NULL,
&dwResumeHandle);
thanks!
|
|
|
|
|
|
Hi,
Can anybody tell me what is the difference between DirectX sdk and DirectX interfaces that is If iam using DirectX Dec 2006 release sdk and DirectX8 interface(what is the difference between this two)???
Thanks in Advance.
Siddharth
|
|
|
|
|
The SDK is the software development kit. DirectX8 refers to major version 8 of the directX
runtime. For the most part, DirectX interfaces are backward-compatible - if you are using
version 8 then that includes all previous versions.
So, if you are developing using a version of the SDK that supports DirectX version 8 and you run
your software on a machine with DirectX version 9 installed then you're fine. Using version 9
interfaces on a machine with version 8 installed wll not work.
Did that make any sense?
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Hi,
I need to draw something in the background area of the edit control.
I tried to do it in the OnEraseBkgnd. But the text has its own background, so i just made the bk mode transparent using SetBkMode in the CtlColor. Now I could draw the background but the antialiasing of text makes problem. Also there is repainting problem while scrolling.
- NS -
|
|
|
|
|
You need to change the backgroundcolor of a Textbox?
|
|
|
|
|