|
I am working in (Windows Presentation Foundation)WPF with C# environment.
I have created simple DLL for C# with WPF.
but how to call C# DLL from VC++ win32?.
Following code of DLL:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Test
{
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
textBox1.Text = "Welcome to Tessolve";
}
}
}
Actually how to call C# dll function in Vc++ environment?
Please share ur ideas or urls
Regards,
M.Mathivanan
|
|
|
|
|
There is an option to expose C# classes/methods to COM, so you would access them from C++ in that way. Take a look at some of the articles here on CodeProject: try a search for "C# COM".
I must get a clever new signature for 2011.
|
|
|
|
|
|
|
One simple solution is to create a CLI/Interop DLL compiled with /clr, this DLL can export standard C function, which the C++ code can call.
When implementing the standard C functions in the CLI/Interop DLL , then one is able to call standard .NET code, and it is possible for the CLI/Interop DLL to have references to other standard .NET assemblies.
This example hosts a WinForms control in a MFC application, but one could just aswell host a WPF control:
WinFormIntegration Sample: Demonstrates Hosting a WinForms User Control in an MFC Application [^]
modified on Friday, February 25, 2011 10:47 AM
|
|
|
|
|
i want to change quick launch path and start menu shortcut path for existing shortcuts.... also rollback to original path..
|
|
|
|
|
Is this a C++ question?
I must get a clever new signature for 2011.
|
|
|
|
|
There are some articles on CodeProject that will help you get started: here, here, and here.
|
|
|
|
|
In my application initailly i set menu in resource file as
File Display Help Exit
Like this i added first main menu.But dynamically i want to add submenus for Display and Exit.
Under Display,four of five menus should be display.I will add this dynamically by reading it from seperate file.
I tried InsertMenu,Append Menu
but nothing happens.
Pls help me..
Anu
|
|
|
|
|
Anu_Bala wrote: I tried InsertMenu,Append Menu
but nothing happens.
Then you must be doing something wrong, but we cannot guess what happens in your code without seeing some of it.
I must get a clever new signature for 2011.
|
|
|
|
|
Actually i tried
CMenu *pMenuBar = this->GetMenu();
ASSERT_VALID(pMenuBar);
CMenu *pSubMenu = pMenuBar->GetSubMenu(0);
pSubMenu->AppendMenu(MF_STRING | MF_ENABLED, ID_COMMAND_1, "First Item");
pSubMenu->AppendMenu(MF_STRING | MF_ENABLED, ID_COMMAND_2, "Second Item");
By this i can add.but in the mainmenu already one Exit submenu is there.But i dont want that.
So i deleted that sub menu in resource file itself.And when i gave this code it shows assert error.
If i didnot delete Exit menu ,then after running application my FILE menu shows
FILE
Exit
FirstItem
Second Item
Anu
|
|
|
|
|
Anu_Bala wrote: Exit //Actually i dont want this
So can you not just remove it from the .rc file?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
If i remove this Exit from .RC menu editor.When im runnong application it shows Unhandled Exception error.
So what i did,i coded like
pSubMenu->RemoveMenu(0, MF_BYPOSITION);
This will remove the Exit dynamically and then i added my menu by
pSubMenu->AppendMenu(MF_STRING | MF_ENABLED, ID_COMMAND_1, "First Item");
pSubMenu->AppendMenu(MF_STRING | MF_ENABLED, ID_COMMAND_2, "Second Item");
Now i want to rename the main menu text dynamically.
I dont know how can i do that?
Anu
|
|
|
|
|
Anu_Bala wrote: If i remove this Exit from .RC menu editor.When im runnong application it shows Unhandled Exception error.
And that doesn't concern you?
Anu_Bala wrote: pSubMenu->RemoveMenu(0, MF_BYPOSITION);This will remove the Exit dynamically...
Employing a "band-aid" fix is not the right answer.
Anu_Bala wrote: Now i want to rename the main menu text dynamically.
I dont know how can i do that?
How about ModifyMenu() ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
You can override OnInitMenuPopup() and insert and remove menu items there.
What is happening is that your menu template (in the .rc file) is being loaded automatically. Until it is loaded, trying to insert or append will have no effect. OnInitMenuPopup() gives you a chance to modify the menu before it is displayed.
|
|
|
|
|
Anu_Bala wrote: I tried InsertMenu,Append Menu
but nothing happens.
What do those two functions return? Have you tried calling ::InsertMenu() or ::AppendMenu() instead?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
If the menu is already selected into the mainframe at time of modification, you need to call DrawMenuBar() after updating it for changes to take effect (be shown)
If you vote me down, my score will only get lower
|
|
|
|
|
There is a requirement to hide the vertical scrollbar of listbox .
|
|
|
|
|
There is a requirement to hide the vertical scrollbar of listbox when items exceed the display area. There is no option to hide vertical scrollbar but there is a option for to hide horizontal scroolbar.
|
|
|
|
|
Can't you remove the 'Verical scroll' style from the list box property, or remove WS_VSCROLL window style?
|
|
|
|
|
Hi im haveing CPtrList and im adding this list by gettign data from xlsheet.What happened after adding details to list,the list having the same last data.suppose the list count is 3,then 3 listitems are same data.Here the code
CPtrList GrPageList;
void CGraphConfig::OnImportgraph()
{
CString TempString,TempInfo,sExt;
int PointCount=0,iRow=0;
CString sFileName = _T("");
SGrPgConf *pDetl = new SGrPgConf;
if(pDetl == NULL)
{
AfxMessageBox("Memory Allocation Failure ");
return;
}
GrPageList.RemoveAll();
CFileDialog oFileOpen(1,"xls",0,0,"MicroSoft Excel Files(*.xls)|*.xls|Tag Detail Grid File(*.tdl)|*.tdl||");
oFileOpen.m_ofn.lpstrTitle="Import From...";
if(oFileOpen.DoModal() == IDOK)
sFileName=oFileOpen.GetPathName();
sExt=sFileName.Right(3);
sExt.MakeLower();
if(!strcmp(sExt,"xls"))
{
CExcelSheet TagDet(sFileName,"Sheet1",FALSE);
for(iRow=2;iRow <= TagDet.GetTotalRows();iRow++)
{
TagDet.ReadCell(TempString,1,iRow);
pDetl->iPageNo = atoi(TempString);
TagDet.ReadCell(TempString,2,iRow);
sprintf(pDetl->sPageTitle ,"%s",TempString);
TagDet.ReadCell(TempString,3,iRow);
sprintf(pDetl->sPanelDetail[0] ,"%s",TempString);
TagDet.ReadCell(TempString,4,iRow);
sprintf(pDetl->sPanelDetail[1] ,"%s",TempString);
GrPageList.AddTail(pDetl);
POSITION hPos = GrPageList.GetHeadPosition();
while(hPos)
{
SGrPgConf *pData = (SGrPgConf *)GrPageList.GetAt(hPos);
GrPageList.GetNext(hPos);
}
}
TagDet.Commit();
}
}
When i check the list the pData shows the same data(last row - pageno-3.0) three times,GrPageList count is 3.
My XLSheet shows like
PageNo PageTitle FirstKey SecKey
1.0 graph1 Group01 Group02
2.0 graph2 TREND01 TREND02
3.0 graph3 Group01 Group02
Pls help me..
Anu
modified on Thursday, February 24, 2011 1:17 AM
|
|
|
|
|
you are updating the value at the same pointer and adding the same pointer to the CPtrList every time. So all the entries point to same data.
Do SGrPgConf *pDetl = new SGrPgConf; inside the for loop. Remember to delete all entries in list when they are no longer needed.
for(iRow=2;iRow <= TagDet.GetTotalRows();iRow++)
{
SGrPgConf *pDetl = new SGrPgConf;
TagDet.ReadCell(TempString,1,iRow);
pDetl->iPageNo = atoi(TempString);
GrPageList.AddTail(pDetl);
}
|
|
|
|
|
It Works.Thank u so much.
Anu
|
|
|
|
|
In the following function replacing "number - 1" does not yield the same correct result as "--number"? Why is that so? Am I'm missing something?
int sum( int number )
{
int result;
if (number == 1)
return number;
else
{
result = sum(number - 1) + number;
return result;
}
}
|
|
|
|
|
--number changes the value of number, number - 1 does not.
say number is 10:
sum(number - 1) + number; is sum(9) + 10;
and
sum(--number) + number; is sum(9) + 9;
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|