Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
G

Gian

@Gian
About
Posts
43
Topics
22
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Decimal separator and textboxes
    G Gian

    Hello, i've some problems binding decimal values (double) with the TextBox or TextBlock control. The value is showed with the english decimal separator ( . ) and not the local one ( , ) This is an example: http://img135.imageshack.us/img135/3120/xamlny0.png[^] The same problem appears when i create a property in my classes then return (via the get function) a value calculated on the fly. If i bind directly the control with a double property without the get/set functions it works correctly. Do i need to set somewhere the culture? I've tried to change it in the project settings but without solving anything.

    WPF wpf wcf help tutorial question

  • Binding a panel to the selected item type
    G Gian

    Hello, i'm studying WPF for quite a while and i've some problems understanding how to perform a simple implementation i usually use in my programs. I've a treeview representing at the various levels different types of items. When i click on an item i can see a form/property grid/etc showing the attributes of that element so i can modify/see them. Of coruse each type of element has different attributes. There's also another situation when you have a list of items and not a treeview, but each item is logically attached to a serie of data (see for example an options dialog when you have the list of categories on the left and on the right the options of the selected category) I'm thinking about two ways to do that and i'd like your opinions: 1) Assign a window (or i presume, an user control) to a panel on the fly when the selected item is change. Is it possible? There's a way to do that only via xaml? 2) Load each type of details control via xaml and somehow bind the visibily property of each control to the type of the selected item 3) As you can do a datatemplate to represent each item in the treeview, apply different templates to the panel binded to the selected item of the treeview, using the DataType property of the template to bind the correct panel to the current item type. Is it possible? Is there any example of that? Thanks :)

    WPF wpf tutorial csharp css wcf

  • Modal dialog freeze on show
    G Gian

    Hello, i need to show a modal CDialog called from a CFormView. This view has a .NET control in it than when double clicked raise a C++ event function in an helper class that try to open the modal dialog. My problem is that the dialog is shown but after that is freezed, i cant modifity data or move it. That strange thing is that putting a simple MessageBox in any position of the OnInitDialog function the dialog works perfectly. I've tried to remove all the controls in the dialog but no progress. If i open the dialog from a function in the View it has no problem. If i call the function from the control event function it doesnt works. So i've tried also to send a message to the view and open the dialog from there but it doesnt work. What kind of problem is this? Thank you

    C / C++ / MFC csharp c++ help question

  • Add managed event handler function in unmanaged code
    G Gian

    i've found this article http://www.developer.com/net/cplus/article.php/3391571 :)

    Managed C++/CLI csharp c++ help tutorial question

  • Add managed event handler function in unmanaged code
    G Gian

    Hello, i've inserted a .NET control in a MFC Dialog, i'd like to append functions to the events of the component but when i try to do (for example): component1->OnItemMove += new OnItemMoveEvent(this, myFunction) the compiler gives my a C3363 error, saying that i cannot create a delegate for OnItemMoveEvent from a member of a unmanaged class (the dialog class where myFunction is defined) or a non member function. Is there a "trick" to use .NET events from my MFC application or i cant do that in any way? Thank you, Gianmaria

    Managed C++/CLI csharp c++ help tutorial question

  • Add .NET Form into MFC application
    G Gian

    Thank you very much, i'll try the source code provided

    Managed C++/CLI csharp c++ visual-studio com question

  • Add .NET Form into MFC application
    G Gian

    Hello, i need to insert a .NET Form into an MFC application using Visual Studio 2003, is it possible in some way? I've found some articles about doing it with Visual Studio 2005 but nothing more. Is possible is use the form as ActiveX control or what? Thank you, Gianmaria

    Managed C++/CLI csharp c++ visual-studio com question

  • IAsyncResult : how to check a message is completed
    G Gian

    Hello, i'm developing a client-server application and now i need to fix my asynchronously receive of messages because sometimes the complete message is not received on a single OnDataReceived call. I've tried for example to send a 18000 bytes long message with a 40000 bytes long receive buffer but there're 2 incoming packets of 13000 and 5000 bytes. My OnDataReceive function is this public void OnDataReceived(IAsyncResult asyn) { try { // SocketPacket is a class with the buffer of packet SocketPacket socketData = (SocketPacket)asyn.AsyncState ; int iRx = 0 ; // Complete the BeginReceive() asynchronous call by EndReceive() method // which will return the number of characters written to the stream // by the client iRx = socketData.m_currentSocket.EndReceive (asyn); if(iRx > 0) { // this get client object/class data (nickname, receive buffer for this client, socket) ClientSocketType client = GetClientSocket(socketData.m_currentSocket); if(client != null) { // create a new receiving buffer for this server/client receive if(client.PacketBuffer == null) client.PacketBuffer = new MemoryStream(); // append received buffers to that buffer BinaryWriter binwrite = new BinaryWriter(client.PacketBuffer); binwrite.Write(socketData.dataBuffer, 0, iRx); // if packets for this message are finished process message // ?!? WORKING ? if(asyn.IsCompleted) { // prepare the stream and send to a parsing function MemoryStream stream = new MemoryStream(client.PacketBuffer.GetBuffer(), 0, client.PacketBuffer.GetBuffer().Length,true, false); ProcessMessage(socketData.m_currentSocket, stream ); // empty client receive buffer client.PacketBuffer = null; } } // Continue the waiting for data on the Socket WaitForData( socketData.m_currentSocket ); } else { ((SocketPacket)asyn.AsyncState).m_currentSocket.Close(); RemoveSocketFromList(((SocketPacket)asyn.AsyncState).m_currentSocket); AddLogMessage("Disconnected user"); } } catch (ArgumentNullException se) { AddLogMessage(se.Message ); } catch (ObjectDisposedException ) { System.Diagnostics.Debugger.Log(0,"1","\nOnDataReceived: Socket has been closed\n"); } catch

    .NET (Core and Framework) tutorial sysadmin debugging json help

  • Open a form on socket receive
    G Gian

    Hello, i'm developing a Client/Server application and i've to create a Administration Form that opens only when the client is logged like administrator. When i click on the admin button the client request authorization to the server. the server checks if it's an admin and if another admin is logged with admin panels opened, after that sends him a message telling him he can or cannot open the admin form. On the receive of the message i try to open the form but doesnt work. In a modal way the form appears but nothing is displayed in it and i cant close/do nothing. using the form in a modeless way with .Show() only it's the same. So i've tried to make it mdi child of the main form but the program says it cannot make the form parent of something that is in another thread. Is there a way to solve this problem? Thank you very much

    .NET (Core and Framework) sysadmin security help question

  • Catch a Disconnect event in Client-Server Socket enviroment
    G Gian

    Hello, i've setup a simple chat program using the Socket class with Async send and receive. All work good but i cant find an event that from the Server application warn it that a socket connection with a client is disconnected from the client itself. I can send a "disconnection" message from the client before closing the application but it doesnt work if for some kind of problem the program terminates (networking problems, crash of the computer, etc). Thanks in advance for any ideas Gian

    C# sysadmin help lounge workspace

  • Using MDB database with OLEDB/ATL/MFC (from SQL Server)
    G Gian

    I'm programming a little server application in MFC 7.1 + OLEDB that read from a database. I'm using a SQL Server DB (extactly the MSDE version) and all works good, but now i need to store the data in an Access 2000 file, so i've changed the connection parameters like this: CDBPropSet dbinit(DBPROPSET_DBINIT); HRESULT hr; dbinit.AddProperty(DBPROP_AUTH_USERID, OLESTR("Admin")); dbinit.AddProperty(DBPROP_AUTH_PASSWORD, OLESTR("")); dbinit.AddProperty(DBPROP_INIT_DATASOURCE, OLESTR("C:\\Gestu.mdb")); dbinit.AddProperty(DBPROP_INIT_MODE, (long)DB_MODE_READWRITE/*(long)16*/); dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)DBPROMPT_NOPROMPT/*(short)4*/); dbinit.AddProperty(DBPROP_INIT_PROVIDERSTRING, OLESTR("")); dbinit.AddProperty(DBPROP_INIT_LCID, (long)1033); hr = m_DataSource.Open(_T("Microsoft.Jet.OLEDB.4.0"), &dbinit); if (FAILED(hr)) return false; hr = m_session.Open(m_DataSource); if (FAILED(hr)) return false; return true; } the program logins correctly. but when i try to execute a SELECT statement or other accessor operations and execute them it have an error DB_E_ERRORSINCOMMAND. a sample operation is: CCommand DynamicAccessor; CDBPropSet propset(DBPROPSET_ROWSET); propset.AddProperty(DBPROP_CANFETCHBACKWARDS, true); propset.AddProperty(DBPROP_IRowsetScroll, true); propset.AddProperty(DBPROP_IRowsetChange, true); propset.AddProperty(DBPROP_UPDATABILITY, DBPROPVAL_UP_CHANGE); DBROWCOUNT rows; CString sql; sql.Format("SELECT * FROM Users WHERE nickname = '%s';", strNickname); HRESULT hr; hr = DynamicAccessor.Open(m_session, sql, &propset, &rows); if (FAILED(hr)) return false; The same code here works perfectly with the SQL Server connection. Is there some parameters to modify? Thanks

    Database database c++ sql-server sysadmin help

  • Making multi-parameter function
    G Gian

    hello, i need to make a function that accept the same parameters of the Format function of CString and create a formatted string with them so i've declared void OutputMessage(const char* pMessage, ...); and void CNetConnection::OutputMessage(const char* pMessage, ...) { CString msg; va_list argList; va_start( argList, pMessage ); msg.Format(pMessage, argList); va_end( argList ); // next use msg string to do things } The problem is that the output string has incorrect values in the %s %d etc values. I've made something wrong? Thanks

    C / C++ / MFC help question

  • strings in DLL calls
    G Gian

    i've resolved changing CharSet=CharSet.Auto to CharSet=CharSet.Ansi in the function definition :)

    C# csharp c++ data-structures help question

  • strings in DLL calls
    G Gian

    i need to call a function of a C DLL. the function is declared as _EXTERN int __stdcall MyFunction(HWND hWndParent, LPTSTR lpszRow1, LPTSTR lpszRow2, LPTSTR lpszRow3); so i've defined in my c# code [DllImport("library.dll", CharSet=CharSet.Auto)] protected static extern Int32 MyFunction(int hWndParent, StringBuilder lpszRow1, StringBuilder lpszRow2, StringBuilder lpszRow3); in the C/C++ code i have to pass 3 strings of 42 chars (8-bit each) and the function fills the tree with some names. in c# i've created 3 StringBuilder variables and initialized to 42 of both length and max capacity. When i call the function the strings are written but the problem is that each char of the StringBuilder is of 16-bit so 2 characters are in one. Is there a way to extract each single char or to define a StringBuilder of 8-bit elements? I've tried to use string and LPTStr parameters for the function but the DLL doesnt seem to copy anything in my strings. Gianmaria

    C# csharp c++ data-structures help question

  • Sort TreeView items by different logic
    G Gian

    with both the two set of messages there's no retrieval of the TVITEM data and setting of my TVITEM data. It's always 0 all :(( It's hard to think it maybe work ;P

    C# csharp c++ winforms question

  • Sort TreeView items by different logic
    G Gian

    i've implemented the thing in this way: [StructLayout(LayoutKind.Sequential)] public struct TVITEM { public int mask; public IntPtr hItem; public int state; public int stateMask; public IntPtr pszText; public IntPtr cchTextMax; public int iImage; public int iSelectedImage; public int cChildren; public int lParam; } class myTreeNode : TreeNode { public Int32 ItemType; public const int TV_FIRST = 0x1100 ; public const int TVM_GETITEM = TV_FIRST + 62 ; public const int TVM_SETITEM = TV_FIRST + 63 ; public Int32 item_type { set { this.ItemType = value; TVITEM item = new TVITEM(); SendMessage(this.Handle, TVM_GETITEM, new IntPtr(0), ref item); item.lParam = value; SendMessage(this.Handle, TVM_SETITEM, new IntPtr(0), ref item); } get { return this.ItemType; } } [DllImport("user32.dll")] private static extern IntPtr SendMessage( IntPtr hWnd, [MarshalAs(UnmanagedType.U4)] int msg, IntPtr wParam, ref TVITEM item); after adding the node in the TreeView i set the item_type value with my number, and it automatically set the TVITEM lParam value. the problem is that TVM_GETITEM and TVM_SETITEM messages seem to not work :sigh: the TVITEM is not filled but the first message, and the second doesnt set any values in the node. Is the TVITEM structure correct? i've tried also to declared all its properties to IntPtr but with no improvements.

    C# csharp c++ winforms question

  • Sort TreeView items by different logic
    G Gian

    yeah, a node with 2 children ones. i've tested it with a messagebox and i'm sure it's the right node. the function is public void Sort(TreeNode parent, TreeViewSortCallback callback, bool ascending) { TVSORTCB sort = new TVSORTCB(); sort.TreeItemHandle = parent.Handle; sort.Callback = callback; sort.ExtraData = new IntPtr(ascending ? 0 : 1); IntPtr hWnd = this.Handle; SendMessage(hWnd, 4373, IntPtr.Zero, ref sort); } I'm sure that it's the right call because, like i've said, i return -1 in the Compare function, the 2 nodes are inverted. Maybe there's some style of the TreeControl to set or similar?

    C# csharp c++ winforms question

  • Sort TreeView items by different logic
    G Gian

    i've tried in the 2 ways, with ref TVITEM and Marshal but it doesnt work. the first two parameters are always 0 or undefined (using ref TVITEM). i've declared the structure [StructLayout(LayoutKind.Sequential)] public struct TVITEM { public IntPtr mask; public IntPtr hItem; public IntPtr state; public IntPtr stateMask; public IntPtr pszText; public IntPtr cchTextMax; public IntPtr iImage; public IntPtr iSelectedImage; public IntPtr cChildren; public IntPtr lParam; } my second test was with public IntPtr Compare(IntPtr node1,IntPtr node2, IntPtr extraData) { TVITEM item1 = new TVITEM(); Marshal.PtrToStructure(node1, item1); TVITEM item2 = new TVITEM(); Marshal.PtrToStructure(node2, item2); TreeNode node_1 = TreeNode.FromHandle(this, item1.hItem); TreeNode node_2 = TreeNode.FromHandle(this, item2.hItem); but always the first 2 parameters are undefined. I've checked the value of extraData and it's correct, the same value i pass when call the sorting. I cant understand why the handle values of the 2 nodes are not passed to the callback function. However forcing the sorting of the two nodes, the tree updates correcly. But there's no way of testing the values of the 2 nodes. I've created a little test application with only these things, and the behaviour is indentical

    C# csharp c++ winforms question

  • Sort TreeView items by different logic
    G Gian

    thanks for the infos. i've implemented a sort function like this in my TreeView class: public IntPtr Compare(IntPtr node1, IntPtr node2, IntPtr extraData) { TreeNode node_1 = TreeNode.FromHandle(this, node1); TreeNode node_2 = TreeNode.FromHandle(this, node2); IntPtr ret= new IntPtr(0); long prog1 = ((myTreeNode)node_1).item_type; long prog2 = ((myTreeNode)node_2).item_type; if(prog1 < prog2) { ret = new IntPtr(-1); } if(prog1 > prog2) { ret = new IntPtr (1); } return ret; } and call the sort function Sort(parent_node, new TreeViewSortCallBack(Compare), 0); at that point, the Compare function is called but both node1 and node2 are zero valued. is because those values are not the nodes but the ItemData like in MFC?

    C# csharp c++ winforms question

  • Sort TreeView items by different logic
    G Gian

    Hello, i'd like to sort the child items of a node of a Windows Forms TreeView control using a function of my own that set if the node is to be listed before or after another. Every node has a logic code that i've stored internally using a derived class of TreeNode and i'd like to sort the item by this one. In MFC there's the possibility of defining a logic compare function, is there anything similar in .NET? Or there's another way to add a new child node of an item and sort all its childs without removing them and reloading ? Thanks, Gianmaria

    C# csharp c++ winforms question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups