|
so you decided to use some type's ToString() method but you did not consider reading up about it?
|
|
|
|
|
Any advice please on where to find more info on this?
Thanks
|
|
|
|
|
Object.ToString() has several overloads. some accept formatting instructions and culture specifications. You can get help on MSDN (and in visual studio help). You should consult the ToString(0 documentation for the particular type you are concerned with, as the base class virtual methods are often overridden. The help for Int32[^] is typical, and should shed light on your question. There are many links to additional details on formatting in the help article.
|
|
|
|
|
In reply to my question...
textBox1->Text= Variable1.ToString("N0");
textBox1->Text= Variable1.ToString("N2");
textBox1->Text= Variable1.ToString("X");
textBox1->Text= Variable1.ToString("x");
Hope it helps somebody out there like me. I am really amazed there isn't a decent manual on these very basic things... It must all be there on MSDN but I find it the most impossible reference to consult.
|
|
|
|
|
|
Deal all,
I just want to know how can I convert an object to a user defined type pointer in managed C++. I will elaborate my situation. I want to use an ActiveX control in a windows form application written in C#. When we add an ActiveX into a project VS generates the RCW objects. In my case it is
private AxXVIDEOOCXLib.AxXVideoOCX axXVideoOCX1;
Now I will get the underlying ActiveX object using the function
Object obj = axXVideoOCX1.GetOcx();
Now I need to pass this object into a managed C++ dll(.net component). Inside this dll I have a function with prototype in an unmanaged class as follows
int CVideoRecorderCtrl::AddOCXHandle(CXVideoOCX* OCXHandle)
Can any one commment whether my approach is correct? If yes my question is yet to come.
The class CXVideoOCX is the class of ActiveX component. Is there any successful way so that I can convert this COM object to its actual unmanaged type..I am searching for a solution for past 1 week. I will be really really thankful if anyone have any comments on these.
|
|
|
|
|
I was wondering if anybody could give me hand solving this problem. I need to save a DWORD value (DesiredValue) in a registry key and this was the syntax I was using (successfully) in console environment.
DWORD DesiredValue;
HKEY Xtmpkey;
DWORD dwDisp = 0;
LPDWORD xlpdwDisposition = &dwDisp;
DWORD dwVal = DesiredValue;
RegCreateKeyEx(HKEY_CURRENT_USER, L"SOFTWARE\\MyPath", 0L,NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &Xtmpkey,xlpdwDisposition);
RegSetValueEx (Xtmpkey, L"Desired_Value_Name", 0L, REG_DWORD,(CONST BYTE*) &dwVal, sizeof(DWORD));
Now that I am porting the software into C++/CLI environment it returns the following errors:
Error 1 error LNK2001: unresolved external symbol "extern "C" long __stdcall RegCreateKeyExW(struct HKEY__ *,wchar_t const *,unsigned long,wchar_t *,unsigned long,unsigned long,struct _SECURITY_ATTRIBUTES * const,struct HKEY__ * *,unsigned long *)" (?RegCreateKeyExW@@$$J236YGJPAUHKEY__@@PB_WKPA_WKKQAU_SECURITY_ATTRIBUTES@@PAPAU1@PAK@Z)
Error 2 error LNK2001: unresolved external symbol "extern "C" long __stdcall RegSetValueExW(struct HKEY__ *,wchar_t const *,unsigned long,unsigned long,unsigned char const *,unsigned long)" (?RegSetValueExW@@$$J224YGJPAUHKEY__@@PB_WKKPBEK@Z)
Error 3 fatal error LNK1120: 2 unresolved externals
What am I doing wrong?
Thanks in advance.
|
|
|
|
|
You need to link to Advapi32.lib.
#pragma comment(lib, "Advapi32.lib")
Or, since it's managed code, you could use the Microsoft.Win32.Registry Class[^],
which is a tad easier to use than the Win32 APIs.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: You need to link to Advapi32.lib.
#pragma comment(lib, "Advapi32.lib")
You are a "C"enius, it works! I wish one day I could be as smart.
|
|
|
|
|
It's all in the documentation
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
using namespace Microsoft::Win32;
Registry::SetValue("HKEY_CURRENT_USER\\SOFTWARE\\MyPath", "Desired_Value_Name", "Value");
Nigah M Manzoor
|
|
|
|
|
Hi
I have an SQL query which is to be executed from the server. Just before executing, I am checking if the internet is available or not.
I am using InternetGetConnectedState api to implement this.
But this call returns true, for 2-3 seconds after the network connection is lost. This causes the application to hang.
Pls verify my code and check if it is the appropriate code
---------------------------------------------------
[DllImport("wininet.dll",
SetLastError=true,CharSet=CharSet::Unicode,ExactSpelling=true,
CallingConvention=CallingConvention::StdCall)]
static bool InternetGetConnectedState(int &Description, int ReservedValue ) ;
bool IsConnectedToInternet()
{
int Desc ;
return InternetGetConnectedState(Desc, 0 ) ;
}
if (IsConnectedToInternet())
{
mysql_query(mysqlConnectorObject,sqlQuery);
return mysql_store_result(mysqlConnectorObject);
}
else
{
MessageBox::Show("Not connected");
}
----------------------------------------------------
Thanks in advance
Anvesh
|
|
|
|
|
Hi,
InternetGetConnectedState() is the best way I know to look at the Internet connection state.
You are saying it shows a slightly outdated state, but that should not be too bad. Anyway,
the connection could be lost right after you call the function, so the code that follows must
survive that anyway. Hence, use asynchronous code (on a separate thread) and give whatever you
are trying to do a timeout.
|
|
|
|
|
Thank you very much.....
Can you pls tell me how to set the time limit when starting a new thread.
Can you also suggest the most suited class to do this? I mean whether it is backgroundworker, threadpool or thread class?
|
|
|
|
|
anveshvm wrote: how to set the time limit
you either perform calls that support a time limit, or you should launch a (one-shot) timer, which:
- you cancel again when the operation succeeds
- and if the timer fires, you stop the timer and cancel the thread
anveshvm wrote: backgroundworker, threadpool or thread?
whatever fits your circumstances best; since you may have to abort it, threadpool could not be the right choice though.
|
|
|
|
|
Thank you Luc Pattyn.... I will try that way.
|
|
|
|
|
|
I have written a code to check the return value of a message box. But it doesn't work .
My code is
--------------------------------------
DialogResult^ res = MessageBox::Show("Network connection failed.,"Error in connection",MessageBoxButtons::RetryCancel,MessageBoxIcon::Warning,MessageBoxDefaultButton::Button1);
if (res == System::Windows::Forms::DialogResult::Cancel)
{
Application::Exit();
}
else if (res == System::Windows::Forms::DialogResult::Retry)
{
continue;
}
---------------------------------------------------------
Here both the if condition fails...
In immediate window, the value of res is {...}
Pls check it
Thanks in advance
Anvesh
|
|
|
|
|
anveshvm wrote: DialogResult^ res
do you want the ^ there? DialogResult is a value type, isn't it?
|
|
|
|
|
Yeah.... I got it....
Thanks alot
|
|
|
|
|
you're welcome.
|
|
|
|
|
From inside the overriden virtual function of a derived class, how can I call the base class function. The C# equivalent is base.SomeVirtualFunction(); I need VC++ managed equivalent.
Thank you.
|
|
|
|
|
public ref class baseclass
{
public:
virtual void virtualmethod()
{
}
};
public ref class derivedclass : public baseclass
{
public:
virtual void virtualmethod() override
{
baseclass::virtualmethod();
}
};
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
You know it's really funny. C++/CLI forum is serving every other forum. All platform related things are being asked here taking the burden off C# & VB.net forums, and also the OO questions, freeing up the C++ forum
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
This board is so dead it makes me
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|