|
Using CPropertySheet, is there anyway to change the text of the Cancel button?
|
|
|
|
|
pSheet ->GetDlgItem (IDCANCEL) ->SetWindowText ("New Text");
That is assuming pSheet is a pointer to your sheet.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Tim,
I don't know how to do this with CPropertySheet. It gives you the 4 wizard buttons (Back, Next, Cancel, Help) automatically with member functions to manage them. See SetWizardButtons in MSDN. You don't have direct access to the buttons. I don't see a way to change the text on the Cancel Button.
Bob
|
|
|
|
|
Those buttons are just like any other button on a dialog. Get the window and then set the window text.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Hi,
I'm new to writing a service and I've found the following psuedo code for my main function:
for (int i = 1; i < argc; i++)
{
if ((argv[i][0] == TEXT('-')) || (argv[i][0] == TEXT('/')))
{
// Command line switch
if (lstrcmpi(&argv[i][1], TEXT("Service")) == 0)
InstallService();
if (lstrcmpi(&argv[i][1], TEXT("UnRegServer")) == 0)
RemoveService();
if (lstrcmpi(&argv[i][1], TEXT("debug")) == 0)
{
// Execute the service code
ServiceMain(0, NULL);
}
if (lstrcmpi(&argv[i][1], TEXT("service1")) == 0)
{
// Connect to the service control dispatcher
SERVICE_TABLE_ENTRY ServiceTable[] =
{
{ g_szServiceName, ServiceMain },
{ NULL, NULL } // End of list
};
chVERIFY(StartServiceCtrlDispatcher(ServiceTable));
}
}
}
From looking at this code, in order to install and start the service, I would have to call the application passing in -Service then -service1. Is there any way that I can just call -Service then make a call to net start service_name.exe?
Thanks for any help you can provide,
Craig
|
|
|
|
|
Here is what is going on...
When you type the command "XXXX -Service" the program is creating the entry in the service database for your service. One thing you don't see here is that when it creates the entry in the database it is specifying " -Service1" as the command line for the service.
THUS, when you start the service via the control panel or the net command, it is automatically run as "XXXX -Service1". Thus the program sees the "-Service1" parameter and knows that it is being run as a service and not interactively.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Tim,
Thanks for the reply, that seems to make sense but when I do the following at the command prompt this is what I get:
C:\Temp\MyService\Debug>MyService -Service
C:\Temp\MyService\Debug>net start MyService
The service is not responding to the control function.
More help is available by typing NET HELPMSG 2186.
I think this is happening because StartServiceCtrlDispatcher(...) isn't getting called because it never get's to:
if (lstrcmpi(&argv[i][1], TEXT("service1")) == 0)
{
// Connect to the service control dispatcher
SERVICE_TABLE_ENTRY ServiceTable[] =
{
{ g_szServiceName, ServiceMain },
{ NULL, NULL } // End of list
};
chVERIFY(StartServiceCtrlDispatcher(ServiceTable));
}
I'm not sure if this is actually the case but I think it is. Do you have any ideas about this?
Thanks,
Craig
|
|
|
|
|
If what I am thinking is correct, do this.
Run REGEDIT.
Locate the key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\YOUR_SERVICE_NAME
Under that key should be the command line used to start the service stored in the "ImagePath" value. Check to make sure that it looks something like:
"C:\DIR\DIR\DIR\YOUR_SERVICE_PROGRAM.EXE -service1"
If "-service1" is missing, then just as a test, add it to the end of that value. The try the NET START command again. If it works then, make sure that the code creating the service includes the "-service1" string.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Tim,
That is EXCELLENT, you've probably save me a couple days worth of work. Do you happen to know off the top of your head how I can change the default value of that registry setting inside the service? Or, do I have to just manually change that when I install the service?
Thanks again for all your help with this,
Craig
|
|
|
|
|
You shouldn't have to do anything special. Just take a look at your service creation code (look for the CreateService API routine). Instead of just specifying the program name for the 8th argument, append " -service1" to the end of that string and then call CreateService. That should get it done.
Now if the service already exists, you will have to invoke OpenService and then ChangeServiceConfig. In my code I just blindly call CreateService. If it returns ERROR_SERVICE_EXISTS or ERROR_DUP_NAME, then I call OpenService and ChangeServiceConfig to change any service settings.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Tim,
That did the trick. Thanks so much for taking the time to help me with this. I now have a running service .
Thanks again and have a great weekend,
Craig
|
|
|
|
|
Hi
i recently created a completely new hash algorithm "UFH" (Ultra Fast Hash).
This algorithm works relatively simple:
1) fill a hash-byte-array by simply adding the data bytes to the bytes in the array
2) if the end of the array is reached, perform as many PHTs (Pseudo-Hadamard-Transforms) as needed to spread a single bit error over the complete array (for example if the hash length is 4 bytes you have to perform 8 PHTs, 4 forward, 4 backward).
A 8-bit PHT is defined as
x += y
y += x
The hash algorithm is definitely not usage in cryptography, but to check if a file is original the algorithm seems to work very well.
You can download it here.
Please download it and test it.
I am really interested in you opinion. If you think it is well, i perhaps write an article about it.
Thank you very much
Dominik
|
|
|
|
|
Take a look at CRC32. It is very good at detecting errors and works very well at detecting change. If you need even better change detection, MD5 works well.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
I know CRC32 and MD5 (and many more). But MD5 is a cryptographic hash function and it seems that my algorithm is at least as fast as CRC32 and when using longer hashes it seems to be more secure than CRC32. It seems that if increasing the hash size the speed doesn't slow down.
Have a look at the sample.
|
|
|
|
|
Ok, I have found many failures so far.
1. The following two data streams match (all bytes processed in one UFH_HashIn)
unsigned char szData1 [] = { 1, 0x80, 2, 3, 1, 0, 2, 3 };
unsigned char szData2 [] = { 1, 0, 2, 3, 1, 0x80, 2, 3 };
2. These two data streams match (all bytes processed in one UFH_HashIn)
unsigned char szData1 [] = { 0 };
unsigned char szData2 [] = { 0, 0 };
3. These two data stream match (all bytes processed in one UFH_HashIn). This is really a variant on #2.
unsigned char szData1 [] = { 1 };
unsigned char szData2 [] = { 1, 0 };
4. The routine is very depending on how a stream is processed. Given the following stream, if 5 bytes are processed followed by 3 to generate the first hash, and then all 8 bytes are processed to generate a new hash, the resulting values do not match. Thus giving you a false failure to match.
unsigned char szData1 [] = { 1, 0x80, 2, 3, 1, 0, 2, 3 };
Many of the problems you have are the exact problems that CRC-32 try to fix. Now even CRC32 can have a problem with test case #2 *IF* a value of 0 is used for the seed. But the other failures wouldn't happen with CRC32.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
i am doing some very large calculations in a RichEdit and it keeps going into standard form like 546E10 is there a way to stop this?
P.S i am using Borland C++ 5 and oop
|
|
|
|
|
here is my code..
but in the callback function,two messageboxs contains empty string. do you know why?
when i insert an item to the tree, i had set item.lparam = info;
info is CString, which is .txt_2342_5/3/02 , type,size,and date combine in one stentence
i want to sort my tree by date, by size, and by type as window explore does.
any clue???
/*===============================================================================
Sorting a tree using CTreeCtrl::SortChildrenCB()
=================================================================================*/
CTreeCtrl *myTreeCtrl;
static int CALLBACK MyCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
// lParamSort contains a pointer to the tree control.The lParam of an item is just its handle.
CTreeCtrl *pmyTreeCtrl = (CTreeCtrl*) lParamSort;
CString strItem1 = pmyTreeCtrl->GetItemText((HTREEITEM) lParam1);
CString strItem2 = pmyTreeCtrl->GetItemText((HTREEITEM) lParam2);
AfxMessageBox(strItem1);
AfxMessageBox(strItem2);
return strcmp(strItem2, strItem1);
}
//sorting trees
void CSMPprojectDlg::SortTreeItem()
{
// Sort the tree control's items using my callback procedure.
HTREEITEM hRoot = m_TreeCtrl.GetRootItem();
HTREEITEM hNextItem = m_TreeCtrl.GetNextItem(hRoot,1);
while( hNextItem != NULL )
{
m_TreeCtrl.SetItemData(hNextItem,(DWORD)hNextItem);
hNextItem = m_TreeCtrl.GetNextItem(hNextItem,1);
}
myTreeCtrl = &m_TreeCtrl;
TVSORTCB tvs;
tvs.hParent = m_TreeCtrl.GetRootItem();
tvs.lpfnCompare = MyCompareProc;
tvs.lParam = (LPARAM)myTreeCtrl;
m_TreeCtrl.SortChildrenCB(&tvs);
MessageBox("hello");
}
void CSMPprojectDlg::SortingAtree()
{
SortTreeItem();
}
|
|
|
|
|
here is the original code
void Compensate(float XCentroid, float ZCentroid,
float *CompensatedX, float *CompensatedZ)
{
double Dr = 0.0;
double LCentroidX = 0.0;
double LCentroidZ = 0.0;
double VectLength = 0.0;
double FRACTION = 0.009835;
double EXPONENT = 2.400;
LCentroidX = (double)XCentroid;
LCentroidZ = (double)ZCentroid;
VectLength = sqrt( (pow(LCentroidX, 2.0)) + (pow(LCentroidZ, 2.0)) );
Dr = FRACTION * ( pow(VectLength, EXPONENT) );
if ( VectLength != (double)0.0 )
{
*CompensatedX = (float)LCentroidX + ( Dr * ( LCentroidX / VectLength ) );
*CompensatedZ = (float)LCentroidZ + ( Dr * ( LCentroidZ / VectLength ) );
}
else
{
*CompensatedX = XCentroid;
*CompensatedZ = ZCentroid;
}
return;
}
so how can I reverse this algorithm? That is, based on CompensatedX and CompensatedZ, how can I get the original XCentroid and ZCentroid?
I tried the following, but it doesn't work.
CompensatedVect = sqrt(pow(CompensatedX, 2.0), pow(CompensatedZ, 2.0));
CompensatedDr = pow((CompensatedVect/FRACTION), 1/EXPONENT);
XCentroid = CompensatedX / (1 + CompensatedDr/CompensatedVect);
ZCentroid = CompensatedZ / (1 + CompensatedDr/CompensatedVect);
I hope I am posting it in the correct forum this time.
|
|
|
|
|
I wrote a #define macro and I would like to see the output
after it's preprocessed, is there a setting in VStudio
that would show the macro after it is expanded?
.dave.
David Hisel -- http://www.hisel.com/
|
|
|
|
|
From the Property Pages dialog:
- Expand the Configuration folder
- Expand the C/C++ folder
- Click the Preprocessor item
- Change the Generate Preprossed File to the desired setting (line numbers or not in the output file)
When you build the project, you will have preprocessed versions of your files with the .i extension.
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
sorry, but didn't find item 4 (line numbers or not). should I include some C++ macros there?
|
|
|
|
|
What do you see as options on the Preprocessor page? The third item should be labelled "Generate Preprocessed File". You click in that and drop the combo down to see the options.
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
I did a Project->Settings->C/C++ -> Category: Preprocessor, and what I see is:
Preprocessor definitions (edit box)
UnDefined symbols: (check box, followed by an edit box)
Additional include directories: (edit box)
Ignore standard include paths (check box).
What did I miss?
|
|
|
|
|
Oh. Are you running VS6? I'm running VS.NET.
If you're running VS6, what you need to know is the following:
- Create preprocessor file - add /P to the CL call
- Create preprocessor file (with line numbers) - add /EP and /P to the CL call
Therefore, either look through for the pages for this option or manually add it.
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
got it. Thank you, Tom.
In VS6, it's add /P or /EP (output is the output window of VS6) in Project Options of Project->Settings->C/C++ ->Category: Preprocessor.
|
|
|
|
|