|
The menu bar isn't traditionally a window. Don't try looking up Explorer or Internet Explorer using Spy++, though, as that will indicate a window handle... of a toolbar. Ditto Visual Studio and Office.
You can owner-draw menu items by adding the MFT_OWNERDRAW flag to the menu item using SetMenuItemInfo . Windows then sends the window WM_MEASUREITEM and WM_DRAWITEM messages.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
i am facing a weird problem
i am using XP icons imporitng them adding them to the imagelist attaching it with the ctreeview
m_ImageList.Create(16,16,ILC_COLOR32|ILC_MASK,4,4);
m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICON1));
GetTreeCtrl().SetImageList(&m_ImageList,TVSIL_NORMAL);
But the Icons don't show right (seems they are painted with less colors)
but he same code and same icons are wokring with CListCtrl just fine
any ideas , can CImagelist handle such icons it must cause CListCtrl is painting them just right
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
http://www.mastishk.com
|
|
|
|
|
Here is a snippet of code I wrote last month. It makes a CTreeview with a list of icons (big size) on the left with a description on the right side (2nd column). Dont forget, icons have 2 sizes, small and big. See if you can understand what I wrote:
CImageList * m_pImageList;
CImageList * m_pImageListSmall;
<view file="">
// insert two columns (REPORT mode) and modify the new header items
m_ctlDatabaseList.GetWindowRect(&rect);
m_ctlDatabaseList.InsertColumn(0, strItem1, LVCFMT_LEFT, rect.Width() * 3/9, 0);
//spaces them equally. This is a header of the CTree control
m_ctlDatabaseList.InsertColumn(1, strItem2, LVCFMT_LEFT, rect.Width() * 1/3, 1);
m_ctlDatabaseList.InsertColumn(2, strItem3, LVCFMT_LEFT, rect.Width() * 2/7, 2);
///create the icons
CRect rect;
CzScanApp *pApp;
pApp = (CzScanApp*)AfxGetApp();
m_pImageList = new CImageList();
m_pImageListSmall = new CImageList();
ASSERT(m_pImageList != NULL && m_pImageListSmall != NULL);// serious allocation failure checking
m_pImageList->Create(32, 32, TRUE, 4, 4); //This is a large icon
m_pImageListSmall->Create(16, 16, TRUE,4, 4);//this is the small icon from the same file
m_pImageList->Add(pApp->LoadIcon(IDI_ICON1));
//Icons have 2 sides to them, small size and large size
//.....ADD AS MANY ICONS YOU WANT SO LONG AS YOU HAVE THE ICON FILES STORED TO USE
m_pImageList->Add(pApp->LoadIcon(IDI_ICON50));
//Icons have 2 sides to them, small size and large size
///now add the icons to show
for (iItem = 0; iItem < Limit; iItem++) // insert the items and subitems into the list view.
{
if(GROUP[iItem+1][0].NoOfDACs== 0)
continue;
for (iSubItem = 0; iSubItem < 3; iSubItem++)
{
if (iSubItem == 0)
iIcon = ++a; // choose the icon and legend for the entry
lvitem.mask = LVIF_TEXT | (iSubItem == 0? LVIF_IMAGE : 0);
lvitem.iItem = (iSubItem == 0)? iItem : iActualItem;
lvitem.iSubItem = iSubItem;
// calculate the main and sub-item strings for the current item
pStrTemp1= strIconShortDesc[iIcon].GetBuffer(strIconShortDesc[iIcon].GetLength());
pStrTemp2= strIconDesc[iIcon].GetBuffer(strIconDesc[iIcon].GetLength());
pStrTemp3= strIcon3rdCol[iIcon].GetBuffer(strIcon3rdCol[iIcon].GetLength());
//lvitem.pszText = iSubItem == 0? pStrTemp1 : pStrTemp2;//2;
switch(iSubItem)
{
case 0:
lvitem.pszText = pStrTemp1;
break;
case 1:
lvitem.pszText = pStrTemp2;
break;
case 2:
lvitem.pszText = pStrTemp3;
break;
default:
break;
}
lvitem.iImage = iIcon;
if (iSubItem == 0)
iActualItem = m_ctlDatabaseList.InsertItem(&lvitem);
// HERE, IT INSERTS A NEW ICON WITH A DESCRIPTION
else
m_ctlDatabaseList.SetItem(&lvitem);
// HERE, IT MODIFIES AN EXISTING ICON WITH DESCRIPTION, (the sub-item text)
}//for(iSubItem
|
|
|
|
|
when test my program using rational purify it shows
memory leak.
the memory leak is shown in recv()
/* message, as shown by rational purify */
[W] MLK: Memory leak of 48 bytes from 1 block allocated in recv [WSOCK32.dll]
Distribution of leaked blocks
48 bytes from 1 block of 48 bytes (0x001bad90)
Allocation location
RtlAllocateHeap [NTDLL.DLL]
recv [WSOCK32.dll]
mainThread(void) [mainthread.h:70]
wndProc(HWND__ *,UINT,UINT,long) [wndproc.h:199]
PeekMessageA [USER32.dll]
msgLoop(void) [esme.cpp:61]
WinMain [esme.cpp:107]
WinMainCRTStartup [crt0.c:198]
/* in program */
BYTE bt[750];
int rcvd=0;
rcvd = recv(sckID,(char *)bt,500,0);
|
|
|
|
|
Did you call shutdown to close the connection (TCP only), closesocket to close the socket, and WSACleanup to clean up the Windows Sockets stack?
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
hello,
I've just bought an AMD64 processor, and I'm coding a new console apps using CRT libraries, I need to get file size lenght but I don't know if I'm really low with skill coding (maybe) or if it's some problem with the architecture I've and the following code
<br />
long FileSize(FILE *fd)<br />
{<br />
long siz=0;<br />
if( fd == NULL)<br />
{<br />
return -1;<br />
}<br />
<br />
fseek (fd, 0, SEEK_END);<br />
siz=ftell(fd);<br />
rewind(fd);<br />
fclose(fd);<br />
<br />
return siz;<br />
};<br />
this piece of code is called at
<br />
wav->fd =fopen(argv[1],"rb");<br />
<br />
if(wav->fd == NULL)<br />
{<br />
printf("Unable to obtain an handle to %s\n",argv[1]);<br />
exit(-1);<br />
}<br />
strncpy((wav)->filename,argv[1],strlen(argv[1]));<br />
wav->filelenght =FileSize(wav->fd);<br />
in the main.
I always obtain 0... I just want to know if someone else is coding with AMD64 and has success with those API, thanks
|
|
|
|
|
I doubt your problem is the CPU.
Anyway, try removing or correcting this line. It is incorrect:
<br />
strncpy((wav)->filename,argv[1],strlen(argv[1]));<br />
Should be:
<br />
strncpy(wav->filename,argv[1],sizeof(wav->filename)-1);<br />
Bikram Singh
|
|
|
|
|
Hai All
please help me to track if a particular service is enabled or disabled in a particular host.
for ex:I installed norton internet security in a system.i need to know if the norton internet security is enabled or disabled because another program will run only if norton inetrnet security is disabled.
so please help me in the above problem.
Thanking you
rubin
|
|
|
|
|
helloo buddy i have created the applictaion that will handle this . you can give me your email address i will send you as early as possible
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
This is from MSDN:
DWORD StartSampleService() <br />
{ <br />
SERVICE_STATUS ssStatus; <br />
DWORD dwOldCheckPoint; <br />
DWORD dwStartTickCount;<br />
DWORD dwWaitTime;<br />
DWORD dwStatus;<br />
<br />
schService = OpenService( <br />
schSCManager,
"Sample_Srv",
SERVICE_ALL_ACCESS); <br />
<br />
if (schService == NULL) <br />
{ <br />
MyErrorExit("OpenService"); <br />
}<br />
<br />
if (!StartService(<br />
schService,
0,
NULL) )
{<br />
MyErrorExit("StartService"); <br />
}<br />
else <br />
{<br />
printf("Service start pending.\n"); <br />
}<br />
<br />
<br />
if (!QueryServiceStatus( <br />
schService,
&ssStatus) )
{<br />
MyErrorExit("QueryServiceStatus"); <br />
}<br />
<br />
<br />
dwStartTickCount = GetTickCount();<br />
dwOldCheckPoint = ssStatus.dwCheckPoint;<br />
<br />
while (ssStatus.dwCurrentState == SERVICE_START_PENDING) <br />
{ <br />
<br />
dwWaitTime = ssStatus.dwWaitHint / 10;<br />
<br />
if( dwWaitTime < 1000 )<br />
dwWaitTime = 1000;<br />
else if ( dwWaitTime > 10000 )<br />
dwWaitTime = 10000;<br />
<br />
Sleep( dwWaitTime );<br />
<br />
<br />
if (!QueryServiceStatus( <br />
schService,
&ssStatus) )
break; <br />
<br />
if ( ssStatus.dwCheckPoint > dwOldCheckPoint )<br />
{<br />
<br />
dwStartTickCount = GetTickCount():<br />
dwOldCheckPoint = ssStatus.dwCheckPoint;<br />
}<br />
else<br />
{<br />
if(GetTickCount()-dwStartTickCount > ssStatus.dwWaitHint)<br />
{<br />
break;<br />
}<br />
}<br />
} <br />
<br />
if (ssStatus.dwCurrentState == SERVICE_RUNNING) <br />
{<br />
printf("StartService SUCCESS.\n"); <br />
dwStatus = NO_ERROR;<br />
}<br />
else <br />
{ <br />
printf("\nService not started. \n");<br />
printf(" Current State: %d\n", ssStatus.dwCurrentState); <br />
printf(" Exit Code: %d\n", ssStatus.dwWin32ExitCode); <br />
printf(" Service Specific Exit Code: %d\n", <br />
ssStatus.dwServiceSpecificExitCode); <br />
printf(" Check Point: %d\n", ssStatus.dwCheckPoint); <br />
printf(" Wait Hint: %d\n", ssStatus.dwWaitHint); <br />
dwStatus = GetLastError();<br />
} <br />
<br />
CloseServiceHandle(schService); <br />
return dwStatus;<br />
}
Bikram Singh
|
|
|
|
|
Is there is any way to recieve windows message without DoModal the dialog box,but by creating the object of that class.
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
|
nope that i don't want i don't want to show dialog noe model nor modeless.
is any way to recieve window message without showing the modelor modelless dialog boxes.
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
The message mechanism builds on HWND s, so, for all practical purposes, no.
But there might be an alternative way, if you describe what you want to accomplish rather than how to accomplish it.
|
|
|
|
|
"first thanks for reply "
now let me explain my problem.
i am creating the window service(which is desktop interractive).i am also created Winlogon dll which notify me that some user is logged on or logged on the Work Station.
now problem arise to comuunicate between these two services i am using RegisterWindowMessage to pass information.
here the problem arise the Service can't receive a until dialog is displayed in case of modol dialog
and the in case of modelless dialog ,from wher i will get the desktop window pointer,without that it will not going to listen my registered message.
i think i have explained my problem
thanks,now any suggesstion
ps(socket create some problem in winlogon,so i can't use socket to sned or recieve message)
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
In this case, I would have tried a hidden modeless window. You normally don't need any pointers to the desktop window to get registered messages, why is that in your case?
|
|
|
|
|
first of all thanks for reply.
now back to problem:-
Yeah i tried that also but it not working.,i don't why the service not getting any registered messages.
thanks any way
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
First of all, you could try making a non-service application with a hidden, modeless main window - trying to send registered messages to it.
|
|
|
|
|
Oh my goodness YES. Always get as much functionality as possible working in a basic application, console, windowless whatever before integrating it into a service or COM component. For Services make sure you have logging working also.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
A nice side-effect is that you also quickly learn to write reusable code
|
|
|
|
|
"Oh my goodness YES. Always get as much functionality as possible working in a basic application, console, windowless whatever before integrating it into a service or COM component. For Services make sure you have logging working also.
"
What logging,i can't understand what you quoted
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
sir with all due respect,
i have created a Non service Application.but when i try to send or post registered message ,it not handle by that application.
have you tried that your self(soory if that is rude)
thanks for concern shown by you to help me out
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Alok the programmer wrote:
have you tried that your self(soory if that is rude)
It's ok, I know I sound patronizing
I've sent, posted and broadcasted registered messages, WM_APP- and WM_USER-based messages to applications, windows and dialogs in every combination you might imagine, as well as some you wouldn't want to hear of.
You mention that you need a pointer to the desktop to receive messages, which makes me suspect that you either have some fundamental misconceptions about the message driven structure of Windows, or that you have some really unusual needs or structure of your application that you might need to explain.
So, what kind of non-service application did you create? How did you send/post/broadcast the message? Where and how did you try to handle it in the application? Inquiring minds needs to know
|
|
|
|
|
i created simple dialog based Application
if you want i will send you code of that application
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
The dialog-based application is only one part of the communication - how do you identify it when sending the message? It's quite enough if you start by posting the code registering and sending the message from the sender, and the code registering the message, the message handler and the message map entry here.
|
|
|
|
|