|
Here are the requested details :
I have the code and following error (C++ /CLI)
<br />
Rectangle ^ClientResolution = gcnew Rectangle();<br />
<br />
ClientResolution = Screen::GetBounds(); <br />
<br />
float CurrentWidth = 1366 ;<br />
float CurrentHeight = 768;<br />
<br />
float RatioWidth = ((float)ClientResolution->Width / (float)CurrentWidth );<br />
<br />
float RatioHeight =((float)ClientResolution->Height / (float)CurrentHeight);<br />
<br />
this->Scale(RatioWidth,RatioHeight); <br />
// error C2661: 'System::Windows::Forms:: Screen::GetBounds' : no overloaded function takes 0 arguments
|
|
|
|
|
There can be more than one monitor but if you only care about the primary monitor, try this:
Rectangle^ ClientResolution = Screen::PrimaryScreen->Bounds;
John
|
|
|
|
|
Thanks John also about the point which you indicated. Hovewer this time application's all windows are maximised which is actually not much preferable. I guess you already have a better idea to fix
the problem. Let me know please.
|
|
|
|
|
We still don't have enough info to guess the problem you're trying to solve.
Based on your code and follow-up here's what I think you are saying:
You have an application with maximized windows but they do not cover the entire desktop and you would like them to. What should you do to make them cover it? ie. you want a full-screen app.
OR possibly...
The application windows are maximized and hiding things and you want them scaled smaller?
OR
neither of these. Please add some more detail about what the current situation is and what the desired situation is.
John
|
|
|
|
|
fzerd wrote: System::Windows::Forms:: Screen::GetBounds' : no overloaded function takes 0 arguments
In which case why not check out the definition of the method you are calling here[^]?
I must get a clever new signature for 2011.
|
|
|
|
|
It's allright Screen::GetBounds(this->ClientRectangle)
Suprisingly it didn't work well. The width of the forms just became a little smaller.That's all.
The application still has a screen size or resolution problem. I am really confused.
|
|
|
|
|
fzerd wrote: The application still has a screen size or resolution problem. I am really confused.
Me too, as you have not made clear exactly what your problem is.
I must get a clever new signature for 2011.
|
|
|
|
|
Sorry i could't see the post. Of course , i am going to explain a simple version of my problem on an empty project. It is a C++ /cli desktop application.( .NET 3.5 )
On development machine (1280 by 720 pix) :
The application has two forms and a button.All form states are normal(default setting)I just customized to their sizes 100x150 and 150x100. That's all.
On client machine (1024 by 768 pix) :
A copy of the application's .exe was copied and clicked. It seems that initially all forms became maximized unexpectedly.
Any idea ?

|
|
|
|
|
fzerd wrote: Any idea ?
Not really, I have not seen this problem. I can only suggest you check all your settings in your forms and start up code to ensure nothing is maximising the windows.
I must get a clever new signature for 2011.
|
|
|
|
|
Hi!
I've to get the string from the String Table. I used the following code:
wchar_t myDocs[1024];
::LoadString(NULL,IDS_USERNAME_CH,myDocs,1024);
It shows the following error:
error C2065: 'IDS_USERNAME_CH' : undeclared identifier
I've to read the string(with ID IDS_USERNAME_CH) from the string Table and set the Text to a label. How to do this in C++/CLI?
|
|
|
|
|
That message seems fairly clear, check where have you defined IDS_USERNAME_CH and make sure it is included in the module you are trying to compile.
I must get a clever new signature for 2011.
|
|
|
|
|
Hi,
I have
System::String ^ St = gcnew System::String("Hey ho!");
std::string str("standard");
St = str;
The only way I can make it work is by doing gcnew again St = gcnew System::String(str.c_str()); but I'm guessing this is not the right way. All the examples I have found tell how to do this when creating a new instance of System::String but none how to do it with an existing one.
|
|
|
|
|
System::String() has no constructor that accepts a std::string Try this:
St = str->c_str();
I must get a clever new signature for 2011.
|
|
|
|
|
Tried it, no good.
error C2664: 'void System::Windows::Forms::Control::Text::set(System::String ^)' : cannot convert parameter 1 from 'const char *' to 'System::String ^' <br />
|
|
|
|
|
Sorry, I guess there is no simple way to do this other than :
St = gcnew System::String(str.c_str());
I must get a clever new signature for 2011.
|
|
|
|
|
Fair enough. That's what I'd done, but... am I not re-allocating memory without freeing it first?? (I have to do it for a dozen of strings!)
|
|
|
|
|
piul wrote: am I not re-allocating memory without freeing it first?
It depends on the actual structure of your code. I think a more pertinent question would be: why are you using both std::string and System::String when you only really need one of them, probably the latter. For example code such as:
std::string str("Some string");
System::String ^ st = gcnew(str.c_str());
serves no real purpose, in that the std::string is totally redundant.
I must get a clever new signature for 2011.
|
|
|
|
|
what about
St = gcnew String(str);
or
using namespace System::Runtime::InteropServices;
...
...
St = Marshal::PtrToStringAnsi((IntPtr)str);
|
|
|
|
|
Hi!
I've set the Text to my label from an XML file. I need to set a chinese word to a label. Here is my XML file contents:
<?xml version="1.0" encoding="UTF-8" ?>
<Remember>游戏目的是使两手牌的点数越比庄家接近</Remember>
The chinese word is for test purpose only(may not be meaningful word). Here is my code for reading this tag and setting the text to a label.
XmlDocument ^ Config = gcnew XmlDocument;
if(System::IO::File::Exists("Config.xml"))
{
Config->Load("Config.xml");
}
XPathNavigator ^ nav = Config->CreateNavigator();
XPathNodeIterator ^ iter;
iter = nav->Select("download/Remember");
while(iter->MoveNext())
{
System::String ^ ConfigText = iter->Current->Value;
ConfigText->Trim();
}
System::Runtime::InteropServices::Marshal::StringToHGlobalUni(ConfigText);
m_pRemember->Text = ConfigText;
While I execute the program only boxes are displayed in place of the chinese characters. If I open the XML file in a browser, the chinese characters are displayed. What else to do to display the chinese language?
|
|
|
|
|
Where are you displaying the text and seeing the boxes? To the console? To a TextBox or TextBlock?
If they are going to the console, then it probably makes sense that you'd see boxes as the console font is probably not set properly to a font with those characters. Use the system menu to change the font to a unicode font and try again if that's the case.
If it's to a textbox, again, check the typeface you're using. The browser is probably dynamically loading the font glyphs it needs and painting with those.
John
|
|
|
|
|
Hi!
How to set Full Control & Write Unlock to a file from C++/CLI? The reason why I want this is:
I'm creating a log in form. While clicking a button, I'm writing the log in information to a file(to implement "Remember Me" functionality). While creating installer for this application, this works fine under Win XP. But did not work with Windows 7. There I've to manually set Full Control to the file. Users of my app won't like this. I used the following code to set Access control:
path = L"RememberMe.ini"; System::IO::File::SetAccessControl(path,System::Security::AccessControl::FileSecurity::WriteUnlock());
But this results in the following error:
error C3767: 'System::Security::AccessControl::ObjectSecurity::WriteUnlock': candidate function(s) not accessible
How to set access control from C++/CLI? or Can any one suggest an alternative solution to my problem? I'm using Visual Studio 2008 Deployment Project to write setup file.
modified on Friday, March 4, 2011 1:59 AM
|
|
|
|
|
pix_programmer wrote: error C3767: 'System::Security::AccessControl::ObjectSecurity::WriteUnlock': candidate function(s) not accessible
You are trying to access a protected method. WriteUnlock() is a protected method and won't be accessible from outside the class.
pix_programmer wrote: While creating installer for this application, this works fine under Win XP. But did not work with Windows 7. There I've to manually set Full Control to the file.
From Vista onwards, you need to utilize the program data folders to write information like this. You will have full write access to these folders.
pix_programmer wrote: How to set access control from C++/CLI
Look at the MSDN documentation[^] for SetAccessControl() method.
Best wishes,
Navaneeth
|
|
|
|
|
Hi all,
I'm working on a user control which is basicly a customized edit control (HexEditBox).
It has a context menu which is activated by the right mouse click, as per normal.
All is working fine with the control, but has a visual aspect that I'm not happy with.
When the context menu is activated the caret is hidden from the control.
For most of the menu items this is irrelevant, but for the paste option the user looses
visual indication where the paste will occur.
It is anyway possible the prevent the context menu from hiding the controls caret?
Thanks in advance .. Milton
|
|
|
|
|
|
I have a C# method declared as:
public static bool MethodName(double [] d1,....)
and am try to call it from a C++ mixed mode method. I have tried to to so as follows:
array<double ^,="" 1=""> ^d = gcnew array<double ^,="" 1="">(2);
d[0] = gcnew double
d[1] = gcnew double
d[0] = 1.0;
d[1] = 2.0;
classname::MethodName(d);
I get a compler error saying cannot convert param 1 from cli::array<type, dimmension=""> ^ to cli::array<Type, dimmension> ^
Does anyone have any ideas on how to correctly pass an arry from C++ to c#?
|
|
|
|