|
Hi PJ Arends
Thanks!
LPSTR also gives a name of a program with it`s complete path.
Anyway thanks a lot.
Bye
Adarsh
|
|
|
|
|
I tried to use CTreeCtrl::SetItemState, setting the flag TVIS_SELECTED. But I found that only one items was highlighted. How can I highlight a set of items? Thanks
|
|
|
|
|
TreeCtrl does not natively support multiple selection you will probably need to track selection state externally and use customdraw etc etc. Maybe block tvn_selectionchanging, listen to mouse leftclick and evaluate it in conjunction with keyboard state using HTREEITEM TreeView_HitTest(HWND hwndTV, LPTVHITTESTINFO lpht) or similar. Its not a simple ask.
You also need to define behaviour such as whether selecting a parent node auto selects all its children and whether the user can select nodes at varying different levels of the tree at the same time.
|
|
|
|
|
How could I highlight certain items in CTreeCtrl? I tried to use CTreeCtrl::SetItemState(),setting the flag as TVIS_SELECTED. But only one item was highlighted. Thanks.
|
|
|
|
|
AKAIK, it is only possible to select one item in the standard CTreeCtrl . Look in the CP articles for some enhanced CTreeCtrl .
~RaGE();
|
|
|
|
|
Hi, I wrote an application to make an exe a service.
it is a console based application(with a simple menu to create, delete, start, stop etc of service).
I can see my service added to services but when i try to start that service through my program or even manually I am getting 1053 error
can any body know why this error comes?
please help me yaar.
if you want i can give the code also.
thanks in advance
Harinath Reddy
HOneywell Technology Solutions Lab,
Bangalore,
India-560076
harinath@vandemataram.com
|
|
|
|
|
my purpose is to start a service which will put an icon in system tray.
and I already explained the problem.
now i did minor modification.
i added SERVICE_INTERACTIVE_PROCESS also for the 5th parameter of Create parameter.
<br />
SC_HANDLE schService;<br />
schService = CreateService( <br />
schSCManager,
lpszServiceName,
lpszDisplayName,
SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS| SERVICE_INTERACTIVE_PROCESS,
SERVICE_DEMAND_START,
SERVICE_ERROR_NORMAL,
lpszBinaryPathName,
NULL,
NULL,
NULL,
NULL,
NULL);
now it seems service is starting (i can see icon on system tray but after a minute it is diappearing and i am getting the same old error (1053)
same thing through program and manually also.
any more ideas pls
Harinath Reddy
HOneywell Technology Solutions Lab,
Bangalore,
India-560076
harinath@vandemataram.com
|
|
|
|
|
1053 means The service did not respond to the start or control request in a timely fashion.
You have to report to the SCM that your service is up and running using the SetServiceStatus() function...
If a service don't do that, the SCM think it hangs and kill it.
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
![Go to Parent](https://www.codeproject.com/App_Themes/CodeProject/Img/arrow-up24.png) well, Thank you very much for your help. I understood the logic.
But where should i do that? let me put the question in other way. see the following is my code for starting the service (i took it from msdn)
<br />
DWORD StartSampleService(SC_HANDLE schSCManager) <br />
{ <br />
SERVICE_STATUS ssStatus; <br />
DWORD dwOldCheckPoint; <br />
DWORD dwStartTickCount;<br />
DWORD dwWaitTime;<br />
DWORD dwStatus;<br />
SC_HANDLE schService;<br />
CString cstrMessage,cstrCaption;<br />
cstrCaption="Service Message";<br />
<br />
char ServiceName[50];<br />
LPCTSTR lpszServiceName;<br />
cout<<"Enter the Name of the service: ";<br />
cin>>ServiceName;<br />
lpszServiceName=(LPCTSTR)ServiceName;<br />
<br />
<br />
schService = OpenService( <br />
schSCManager,
lpszServiceName,
SERVICE_ALL_ACCESS);
<br />
if (schService == NULL) <br />
{ <br />
cstrMessage="OpenService";<br />
cout<<"Error code "<<GetLastError()<<endl;<br />
}<br />
<br />
if (!StartService(<br />
schService,
0,
NULL) )
{<br />
cstrMessage="OpenService";<br />
cout<<"Error code "<<GetLastError()<<endl;<br />
}<br />
else <br />
{<br />
<br />
cstrMessage="Service start pending.\n";<br />
cout<<"Error code "<<GetLastError()<<endl;<br />
}<br />
<br />
<br />
if (!QueryServiceStatus( <br />
schService,
&ssStatus) )
{<br />
cout<<"QueryServiceStatus"<<endl; <br />
cout<<"Error code "<<GetLastError()<<endl;<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 />
<br />
cstrMessage="StartService SUCCESS.\n";<br />
<br />
dwStatus = NO_ERROR;<br />
}<br />
else <br />
{ <br />
cstrMessage="\nService not started. \n";;<br />
cout<<" Current State : "<<ssStatus.dwCurrentState<<endl; <br />
cout<<"Exit Code: "<<ssStatus.dwWin32ExitCode<<endl; <br />
cout<<" Service Specific Exit Code:"<<ssStatus.dwServiceSpecificExitCode<<endl; <br />
cout<<" Check Point: "<<ssStatus.dwCheckPoint<<endl; <br />
cout<<" Wait Hint :"<<ssStatus.dwWaitHint<<endl; <br />
dwStatus = GetLastError();<br />
} <br />
<br />
CloseServiceHandle(schService); <br />
return dwStatus;<br />
<br />
<br />
}<br />
<br />
where should i do the changes?
any further help?
thank you very much again.
cheers
harinath
Harinath Mallepally
HOneywell Technology Solutions Lab,
Bangalore,
India-560076
|
|
|
|
|
Ok, this may sound rather dumb, but this problem is irritating me greatly:
In using the CButtonST class I declared this in my code:
CButtonST *buttonArray[10][20]
One would normally think that this would create a 10x20 matrix, but in my program it creates a 20x10 matrix instead! Does anyone know why this is so? I tried to make a different array of the same size, but it too was reversed. Is there something that I'm missing in my code?
Any help would be much appreciated.
|
|
|
|
|
Taken from MSDN......
Array
An array is a collection of like objects. The simplest case of an array is a vector. C++ provides a convenient syntax for declaration of fixed-size arrays:
Syntax
decl-specifiers dname [ constant-expressionopt ] ;
The number of elements in the array is given by the constant-expression. The first element in the array is the 0th element, and the last element is the (n-1th) element, where n is the size of the array. The constant-expression must be of an integral type and must be greater than 0. A zero-sized array is legal only when the array is the last field in a struct or union and when the Microsoft extensions (/Ze) are enabled.
Arrays are derived types and can therefore be constructed from any other derived or fundamental type except functions, references, and void.
Arrays constructed from other arrays are multidimensional arrays. These multidimensional arrays are specified by placing multiple [ constant-expression ] specifications in sequence. For example, consider this declaration:
int i2[5][7];
It specifies an array of type int, conceptually arranged in a two-dimensional matrix of five rows and seven columns
5 ROWS X 7 COLUMNS!
|
|
|
|
|
That's not my problem though. I know what a matrix is and how to declare one; it's that my
CButtonST *buttonArray[10][20]
matrix is making a matrix of 20 rows X 10 columns, which is in the wrong order.
|
|
|
|
|
Since you haven't given much detail, here is just a wild stab. I am assuming you are thinking in your code not of "row" and "column" but perhaps as "x" and "y". What you have written ("buttonArray[10][20]") we know to be 10 rows of 20 columns, but if you think of it as "x" and "y" you may get your loop indexes reversed.
Since "x" and "y" relate to a Cartesian coordinate system, the "x" axis is typically the horizontal axis, but it actually measures columns (which increase horizontally). Likewise, "y" is the vertical axis and it measures rows.
Therefore, and again this is just a wild stab, if you are programming using "x" and "y" as your loop index variables, you are going to want to reference elements in the array as "buttonArray[y][x]" just as you would if you were using "row" and "col" (buttonArray[row][col]).
What is it that is telling you that the array is actually [20][10] instead of [10][20]?
Dave
"You can say that again." -- Dept. of Redundancy Dept.
|
|
|
|
|
Help me please, i need some data packing algoritms for text/binary data's.
thank you !
|
|
|
|
|
Try out "ZLIB" it is GNU but it is worth it...
|
|
|
|
|
If you look for example at the folder icon in windows on XP you see it has a small 1-2 pix shadow on it. But when I draw the image this "shadow" get completly black.
And make everything look strange. You get the icon with a black line around the image.
I tried everything. (well, perhaps not ) I created the ImageList with different color depths ILC_COLOR32 / ILC_COLOR24 / ILC_COLOR16 and draw the image with different parameters, But nothing help
Anyone know how to draw them ??
|
|
|
|
|
After many hours of searching the Net and news group I found the answers.
The System Icons on XP have a Alpha channal and it is this that is drawn black.
To make it draw correctly on XP I had to include a "manifest" into my project.
So comctl32.dll version 6.0 is started insted of 5.x
|
|
|
|
|
I am computing average of some readings. For each reading I am taking n samples .
My steps are 0 , 0.5, 1.0 .... till 4.5 after which the increments are smaller like 4.5, 4.6,4.7,4.8...
I am doing the following comparision
float vin ;<br />
float x;<br />
loop <br />
if((vin==x) ){<br />
Compute sum for this vin value ; i.e sum =sum + newValue <br />
samples++<br />
}<br />
else{<br />
if(vin!=x ){<br />
sampleArray[sampleCount].thisAverage=sum/(samples);<br />
sampleCount++;<br />
if(x>4.5)<br />
vin+= 0.10000; <br />
else<br />
vin+=0.5;<br />
<br />
samples=1;<br />
}<br />
}
What I am observing is this
everything works Okay until vin reaches 4.80000
There is a comparision done as shown in code above
if((vin==x) ){<br />
Compute sum for this vin value ; i.e sum =sum + newValue <br />
samples++<br />
}
using debug I am able to see that both vin and x are 4.80000 but
the expression (vin==x)evaluates to 0 and the "else" code kicks in !!!
definately there is something weird going in here which I am unable to grab ! I need some help understanding this !!! Please help
|
|
|
|
|
When doing comparision between float(or double), you'd better take into account precision.
for example something like :
double fSomeTolerance = 0.0001;
if ( fabs(vin - x) < fSomeTolerance )
{
ASSERT( 0 );
}
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
i do get ur point, but then why do my previous comparisions for
0.5,1.0,1.5......4.5,4.6,4.7 work ok ?
|
|
|
|
|
4.8 was probably just the point where the tolerance of the comparison started to make a difference. Rounding errors are a similar problem that can not make itself shown for awhile, but the cumulative effect of a lot of operations finally cause an error down the road.
|
|
|
|
|
Very good!
Why? Because comparing floats and doubles for equality is notoriously unreliable, it is some thing you just don't do.
|
|
|
|
|
Hi!!!
I am currently writing OnContextMenu handler. This is supposed to show Shortcut menus when the user presses Right click.
The menu is coming up right but none of the text shows up. Can someone point me to some example which has implemented this or let me know if you have written this part of UI code?
Thanks in advance.
P.S. Windows API Gui is way too whacked. But once it all comes together it is cool
|
|
|
|
|
Post an example of the code that creates and displays the context menu.
Kuphryn
|
|
|
|
|
HMENU hPopMenu = NULL;
MMMENUITEMINFO lpCoolMenuItemInfo, lpCoolMenuItemInfo1;
if (!hPopMenu) hPopMenu = ::CreatePopupMenu();
//lpCoolMenuItemInfo.hSubMenu = NULL;
//lpCoolMenuItemInfo.HotImageListIndex = ::LoadIcon(NULL, MAKEINTRESOURCE(IDI_TEST));
//lpCoolMenuItemInfo.NormalImageIndex = ::LoadIcon(NULL, IDI_TEST);
strcpy(lpCoolMenuItemInfo.szText, "Test 1"); //"Context Menu";
lpCoolMenuItemInfo.uPos = 0;
lpCoolMenuItemInfo.wID = 1;
MENUITEMINFO MenuItemInfo;
MenuItemInfo.fMask = MIIM_TYPE | MIIM_STATE;
MenuItemInfo.fState = MFS_DEFAULT ;
if (lpCoolMenuItemInfo.fType == MFT_SEPARATOR)
{
MenuItemInfo.fType = lpCoolMenuItemInfo.fType;
return InsertMenuItem(hPopMenu,lpCoolMenuItemInfo.uPos,1,&MenuItemInfo);
}
else
{
MenuItemInfo.fMask |= MIIM_DATA | MIIM_ID;
MenuItemInfo.fType = MFT_OWNERDRAW;
MenuItemInfo.wID = lpCoolMenuItemInfo.wID;
MenuItemInfo.cbSize = sizeof(MenuItemInfo);
MMMENUITEMINFOPTR lpcmii = (MMMENUITEMINFOPTR) ::malloc(sizeof(lpCoolMenuItemInfo));
MenuItemInfo.dwItemData = (unsigned long) lpcmii;
::strcpy (lpcmii->szText, "Microsite" ); //lpCoolMenuItemInfo.szText) ;
//lpcmii->HotImageListIndex = lpCoolMenuItemInfo.HotImageListIndex;
//lpcmii->NormalImageIndex = lpCoolMenuItemInfo.NormalImageIndex;
lpcmii->uPos = lpCoolMenuItemInfo.uPos;
lpcmii->fType = MenuItemInfo.fType;
//lpcmii->cAccel = *(p+1);
::InsertMenuItem(hPopMenu,lpCoolMenuItemInfo.uPos,1,&MenuItemInfo);
}
strcpy(lpCoolMenuItemInfo1.szText, "Test Part 2"); //"Context Menu";
lpCoolMenuItemInfo1.uPos = 1;
lpCoolMenuItemInfo1.wID = 2;
MENUITEMINFO MenuItemInfo1;
MenuItemInfo1.fMask = MIIM_TYPE | MIIM_STATE;
MenuItemInfo1.fState = MFS_DEFAULT;
if (lpCoolMenuItemInfo1.fType == MFT_SEPARATOR)
{
MenuItemInfo1.fType = lpCoolMenuItemInfo1.fType;
return InsertMenuItem(hPopMenu,lpCoolMenuItemInfo1.uPos,1,&MenuItemInfo1);
}
else
{
MenuItemInfo1.fMask = MIIM_TYPE | MIIM_DATA;
MenuItemInfo1.fType = MFT_OWNERDRAW;
MenuItemInfo1.wID = lpCoolMenuItemInfo1.wID;
MenuItemInfo1.cbSize = sizeof(MenuItemInfo1);
MMMENUITEMINFOPTR lpcmii1 = (MMMENUITEMINFOPTR) ::malloc(sizeof(lpCoolMenuItemInfo1));
//MenuItemInfo1.dwItemData = (unsigned long) lpcmii1;
MenuItemInfo1.dwTypeData = lpcmii1->szText;
MenuItemInfo1.cch = 256;
::strcpy (lpcmii1->szText, "Test 2" ); //lpCoolMenuItemInfo.szText) ;
//lpcmii->HotImageListIndex = lpCoolMenuItemInfo.HotImageListIndex;
//lpcmii->NormalImageIndex = lpCoolMenuItemInfo.NormalImageIndex;
lpcmii1->uPos = lpCoolMenuItemInfo1.uPos;
lpcmii1->fType = MenuItemInfo1.fType;
//lpcmii->cAccel = *(p+1);
::InsertMenuItem(hPopMenu,lpCoolMenuItemInfo1.uPos,1,&MenuItemInfo1);
}
I have tried doing this using OWNERDRAW and somehow the menu appears but without any text.
Thanks
|
|
|
|