|
I know the facts you say, the function I want to do is the new Item will be added to last pos of listctrl whenever i click the button "New Item", so I need to get the rect whose index is nCount( got by GetItemCount)
So, what should i do?
|
|
|
|
|
I don't think you can get the rect unless the item exists.
Here's what I would try:
When the user clicks "New Item", insert a dummy item using a default text value, like "<type text here>", then call EditLabel. If the user cancels, or the text is invalid, simply remove the item.
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
Do you mean to tell me I cannt get the rect if the list is empty?
Ok, Let me have a try of your method and thanks a lot
|
|
|
|
|
I am using PJ Naughter's CNTService for the purpose. The example service provided by him works fine. But when I try to use his frmaework for my own service application, the service creation works fine but start service always fails with the error 997: overlapped IO operation in progress.
Any help plz.
Rahim Rattani
|
|
|
|
|
Try posting this message to the article itself so that PJ will surely see it. He may not see your question here in the VC++ forum.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
hi..
I want to change the background color of a particular row in CListCtrl.
I know it is possible to do it by using Custom Draw, can you please give me a sample code and if any other easier way to do?
Thanks in Advance
sourabh.
sourabh
|
|
|
|
|
Neat Stuff to do in List Controls Using Custom Draw
The first code snippet almost does what you want. Simply change
<br />
pLVCD->clrText = crText;<br />
to
<br />
pLVCD->clrTextBk = your color here;<br />
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
Why would you post a question about burning cds, on a mac, in a windows programming forum?
It's similar to asking a mechanic how to bake a cake. Try a mac forum.
using System.Beer;
|
|
|
|
|
I am trying to figure out how to use the findfirst or findfirstfile to find the first file
in a given directory.
I want to be able to find the first file that is either:
A bmp or gif or png or a jpg.
So in other words the first image file meeting any of the above four image types.
|
|
|
|
|
|
Yes, I found that but how do you search for a range of file extensions?
This only seems to either do *.* or a specific single file.
|
|
|
|
|
Well I`ll guess you`llhave to do a FindFirstfile followed by a
do - while statement where you check if the file has one of the extensions you are looking for...Something like below...
<code> TCHAR dir[] = { _T("C:\MyPath\Mypics\*.*") };
bool bFoundLegalPic=false;
WIN32_FIND_DATA findData;
HANDLE srchHandle = FindFirstFile(dir, &findData);
if(INVALID_HANDLE_VALUE != srchHandle )
{
do{
//here check last 4 chars of filename (in the finddata variable)
//with the extensions you wish to retrieve
}while(!bFoundLegalPic && FindNextFile(srchHandle, &findData));
FindClose(srchHandle);</code>
Hope this helps you...
Greets,
Davy
|
|
|
|
|
That's not the approach I ended up trying, but probably a better solution than mine.
Thanks.
|
|
|
|
|
Hi Guys,
I am trying to use the Crypt32.lib in one of my VC++ application. i am calling the CryptAcquireContext(&hCryptProv,NULL,NULL,PROV_RSA_FULL,0) function, but i get the following error
Crypt32Dll.obj : error LNK2001: unresolved external symbol _CryptAcquireContext@20
Debug/Crypt32Dll.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
can any of you guys help me on this why i get linking error.
Thank You
Regards
tuscan.
|
|
|
|
|
I've never used this dll, but I've gotten this error when I didn't have the .lib file linked in my project for whatever header I was using
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
hi
i want to know the basic of network programming what things are involved in the network programming. how to make packets of files etc.
ddd
|
|
|
|
|
i use Selchanged event to trace user's selection in tree control. normally it is ok. But when user click the same item twice or more(not double click, there are some long delay between two click), windows will not call selchanged event(I think that windows think there is no change). how can i react the event like this, thank you
Happy Gemini
|
|
|
|
|
Handle the NM_CLICK notification
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
I've been battling around trying to implement WMI into my MFC application. I'm trying to get Windows XP informations such as product key, activation status, ect. I used COM init to interface with Win32_WindowsProductActivation class. I have problems with changing Windows XP Product Key. How can I run SetProductKey method with parameters??? I went through Microsoft docs but it's not clear to me at all. Any hits or sample code??? I've seen VB script but i have difficulty implementing it with C++.
Thank you all
|
|
|
|
|
Can u provide a code snippet of what you are trying to do?
Einstein: "Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."
My Articles
|
|
|
|
|
Hi Aamir,
Thanks for your reply. I don't have problems extracting informations from
Win32_WindowsProductActivation class properties. I have problem using the class methods. In this function i'm trying to pass new product key and change existing one. Can i do it with this SetProductKey method???? or need to use Put method?? Your help is very appreciated. Also well done on that article.
void CKeyFinder::SetWinKey(char * newkey)
{
CoInitialize(NULL);
//Security needs to be initialized
if(CoInitializeSecurity( NULL,
-1,
NULL,
NULL,
RPC_C_AUTHN_LEVEL_PKT,
RPC_C_IMP_LEVEL_IMPERSONATE,
NULL,
EOAC_NONE,
0
) != S_OK)
return;
IWbemLocator *pIWbemLocator = NULL;
IWbemServices *pWbemServices = NULL;
IEnumWbemClassObject * pEnumObject = NULL;
BSTR bstrNamespace = (L"root\\cimv2");
if(CoCreateInstance(
CLSID_WbemLocator,
NULL ,
CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER ,
IID_IUnknown ,
( void ** ) & pIWbemLocator
) != S_OK)
return;
if(pIWbemLocator->ConnectServer(
bstrNamespace, // Namespace
NULL, // Userid
NULL, // PW
NULL, // Locale
0, // flags
NULL, // Authority
NULL, // Context
&pWbemServices
) != S_OK)
return;
HRESULT hRes;
//IWbemServices pointer to make requests of WMI
BSTR strQuery = (L"Select * from Win32_WindowsProductActivation");
BSTR strQL = (L"WQL");
hRes = pWbemServices->ExecQuery(strQL, strQuery,WBEM_FLAG_RETURN_IMMEDIATELY,NULL,&pEnumObject);
if(hRes != S_OK)
{
AfxMessageBox("Could not execute Query");
return;
}
ULONG uCount = 1, uReturned;
IWbemClassObject * pClassObject = NULL;
IWbemClassObject * piObj = NULL;
hRes = pEnumObject->Reset();
if(hRes != S_OK)
{
AfxMessageBox("Could not Enumerate");
return;
}
hRes = pEnumObject->Next(WBEM_INFINITE,uCount, &pClassObject, &uReturned);
if(hRes != S_OK)
{
AfxMessageBox("Could not Enumerate");
return;
}
CString csWin32Activation ("Win32_WindowsProductActivation");
CComBSTR bstrWin32Activation (csWin32Activation);
hRes = pWbemServices->GetObject(bstrWin32Activation,WBEM_FLAG_RETURN_WBEM_COMPLEATE,NULL,&piObj,NULL);
//get the input class for the SetProductKey method
CString csSetProductKey ("SetProductKey");
CComBSTR bstrSetProductKey (csSetProductKey);
hRes = pClassObject->GetMethod(bstrSetProductKey,0,&pClassObject,NULL);
hRes = pClassObject->SpawnInstance(0,&pClassObject);
//SetProductKey takes one argument uint32 SetProductKey(string ProductKey);
CComBSTR bstrNewKey (newkey);
VARIANT v;
VariantInit(&v);
v.vt = VT_BSTR;
v.bstrVal = (BSTR)bstrNewKey;
pClassObject->Put(L"SettingID",0,&v,0);
//Problem is here
//execute the method
// CString csObjName = bstrNamespace + csWin32Activation + "." + "
// CComBSTR bstrObjName(csObjName);
// hRes = pWbemServices->ExecMethod(bstrObjName,bstrSetProductKey,0,NULL,pClassObject,0,NULL);
//error check
if (FAILED(hRes)) {
AfxMessageBox("Could not exec SetProductKey method",hRes);
return;
}
//clean up
VariantClear( &v );
pIWbemLocator->Release();
pWbemServices->Release();
pEnumObject->Release();
pClassObject->Release();
CoUninitialize();
|
|
|
|
|
From MSDN: "This method is valid only if the ActivationRequired property is equal to 1."
Have u checked it.
Plus.. I have run your code and it fails on GetMethod call. Have a look into it again.
Another thing... Why are u trying to call SpawnInstance.
Einstein: "Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."
My Articles
|
|
|
|
|
Dejan Kovac wrote:
I've been battling around trying to implement WMI into my MFC application....I've seen VB script but i have difficulty implementing it with C++.
See here.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hi Dave,
Thanks for reply. You are reading data from class properties.I don't have problem with it at all. My problem is using the class methods. See Win32_WindowsProductActivation class SetProductKey method. How do I implement it??
Cheers
Dejan
|
|
|
|
|
Dejan Kovac wrote:
My problem is using the class methods.
My apologies for the confusion. Most of the questions I see regarding WMI are of the "How do I get access to it?" variety.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|