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
I

iMikki

@iMikki
About
Posts
20
Topics
4
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Managed forms application with 'autosave' wanted
    I iMikki

    Good - I found the solution after some trying and stuff :p (fail, retry, fail again, error, swear, trying, reading, failing again, fixing, waiting, evil laughing, posting the solution on CodeProject) Here is the code I have now:

    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
    System::Threading::Thread ^thd;
    private: System::Void autoSave(void) {
    Threading::Thread::Sleep(5000);
    warningBox("Test? 5000");
    runSave();
    }
    private: System::Void runSave(void) {
    thd = gcnew System::Threading::Thread(gcnew System::Threading::ThreadStart(this, &App2::Form1::autoSave));
    thd->Start();
    }

    private: System::Void LoadFiles(void) {
    runSave();
    //other code
    }

    Works like a charm! I started the app - and 5 second later I got this message! (warningBox(std::string msg) is a messageBox produced by the Windows::Apps thingy... :p Thnx everyone! Edit: This code keeps restarting the thread. :)

    modified on Thursday, December 3, 2009 7:49 AM

    Managed C++/CLI csharp help tutorial question announcement

  • Managed forms application with 'autosave' wanted
    I iMikki

    Quite new yes. I had some CLI C++ at university but never worked with Managed stuff... But I did change the first part to Form1 (referencing to public ref class Form1 : public System::Windows::Forms::Form).. Any way you could help me? :p Or do you might have another idea to realize this 'autosave' thing. The code I currently have is 1400 lines long. :p Kind regards,

    Managed C++/CLI csharp help tutorial question announcement

  • Managed forms application with 'autosave' wanted
    I iMikki

    Thanks for your reply. I currently have this:

    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
    System::Threading::Thread ^thd;
    Form1::MyClass() {
    thd = gcnew System::Threading::Thread(gcnew ThreadStart(this, &Form1::autoSave));
    }

    private: System::Void autoSave(void) {
    Threading::Thread::Sleep(5000);
    warningBox("Test? 5000");
    }

    private: System::Void LoadFiles(void) {
    thd->Start();
    }
    }

    But it doesnt work due the following errors:

    1>d:\app2\app2\Form1.h(61) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>d:\app2\app2\Form1.h(63) : warning C4183: 'MyClass': missing return type; assumed to be a member function returning 'int'
    1>d:\app2\app2\Form1.h(62) : error C2061: syntax error : identifier 'ThreadStart'
    1>d:\app2\app2\Form1.h(62) : error C2143: syntax error : missing ';' before ')'
    1>d:\app2\app2\Form1.h(62) : error C2143: syntax error : missing ';' before ')'

    Managed C++/CLI csharp help tutorial question announcement

  • Managed forms application with 'autosave' wanted
    I iMikki

    1>d:\app2\app2\Form1.h(425) : error C3845: 'App2::Form1::thd': only static data members can be initialized inside a ref class or value type
    1>d:\app2\app2\Form1.h(428) : error C2143: syntax error : missing ';' before '.'
    1>d:\app2\app2\Form1.h(428) : error C2143: syntax error : missing ';' before '.'

    But I corrected Threading::Thread.Sleep(5000); to Threading::Thread::Sleep(5000); which resolved those errors. Now Im still left with C3845.

    Managed C++/CLI csharp help tutorial question announcement

  • Managed forms application with 'autosave' wanted
    I iMikki

    I am building an application where I want to use some kinda autosave function. I found a post about using threads but I cannot find a way to get it working... Currently I have this: LoadFiles() will get run at the beginning of the application. Here should the autosave thread be started...

    public: Threading::Thread thd = new Thread(new ThreadStart(autoSave));
    private: System::Void LoadFiles(void) {
    			Threading::Thread::Start();
    		}
    private: System::Void autoSave(void) {
    			 Threading::Thread.Sleep(5000);
    		 }
    

    And getting the following errors:

    1>d:\app2\app2\Form1.h(424) : error C3845: 'App2::Form1::thd': only static data members can be initialized inside a ref class or value type
    1>d:\app2\app2\Form1.h(58) : error C2512: 'System::Threading::Thread::Thread' : no appropriate default constructor available
    1>d:\app2\app2\Form1.h(426) : error C2352: 'System::Threading::Thread::Start' : illegal call of non-static member function
    1> c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : see declaration of 'System::Threading::Thread::Start'
    1>d:\app2\app2\Form1.h(429) : error C2143: syntax error : missing ';' before '.'
    1>d:\app2\app2\Form1.h(429) : error C2143: syntax error : missing ';' before '.'
    1>Build log was saved at "file://d:\App2\App2\Release\BuildLog.htm"

    Does anyone have any idea how to solve this OR how to make a better thingy? :p Kind regards,

    Managed C++/CLI csharp help tutorial question announcement

  • The SHCreateDirectoryEx function.
    I iMikki

    That works tho! :-O Thanks dude!

    C / C++ / MFC help debugging question

  • The SHCreateDirectoryEx function.
    I iMikki

    Plentyyyyyy lol

    #pragma once
    #include <iostream>
    #include <fstream>
    #include <vector>
    #include <string>
    #include <algorithm>
    #include "Serial/Serial.cpp" //http://www.codeproject.com/KB/system/serial.aspx
    #include "shlobj.h"

    namespace App2 {
    using namespace std;
    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;
    using namespace System::Runtime::InteropServices;

    C / C++ / MFC help debugging question

  • The SHCreateDirectoryEx function.
    I iMikki

    I got an application. So called Windows Forms Application. I will try Directory::CreateDirectory. Thanks again. ---------- Edit: The IDE (Visual C++ Studio 2008 Express) cannot find Directory::CreateDirectory. I might to include some file I guess... ---------- Re-edit: CreateDirectory("c:\test", NULL); works... Sort of - now I get the following error:

    1>d:\app2\app2\Form1.h(304) : error C2664: 'CreateDirectory' : cannot convert parameter 1 from 'const char [7]' to 'LPCTSTR'
    1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

    modified on Friday, November 13, 2009 1:06 PM

    C / C++ / MFC help debugging question

  • The SHCreateDirectoryEx function.
    I iMikki

    Hi guys, Here I am again... But now with another problem :p SHCreateDirectoryEx(NULL, "c:\\text", NULL); gives me the following error:

    1>d:\app2\app2\Form1.h(302) : error C2664: 'SHCreateDirectoryExW' : cannot convert parameter 2 from 'const char [8]' to 'LPCWSTR'
    1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

    I found that _T("..") should work; giving me the following error:

    1>App2.obj : error LNK2028: unresolved token (0A000028) "extern "C" int __stdcall SHCreateDirectoryExW(struct HWND__ *,wchar_t const *,struct _SECURITY_ATTRIBUTES const *)" (?SHCreateDirectoryExW@@$$J212YGHPAUHWND__@@PB_WPBU_SECURITY_ATTRIBUTES@@@Z) referenced in function "private: void __clrcall App2::Form1::saveButton_Click(class System::Object ^,class System::EventArgs ^)" (?saveButton_Click@Form1@App2@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
    1>App2.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall SHCreateDirectoryExW(struct HWND__ *,wchar_t const *,struct _SECURITY_ATTRIBUTES const *)" (?SHCreateDirectoryExW@@$$J212YGHPAUHWND__@@PB_WPBU_SECURITY_ATTRIBUTES@@@Z) referenced in function "private: void __clrcall App2::Form1::saveButton_Click(class System::Object ^,class System::EventArgs ^)" (?saveButton_Click@Form1@App2@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
    1>D:\App2\Debug\App2.exe : fatal error LNK1120: 2 unresolved externals

    Does anyone have experience with this function. I want to make a (n absolute) folder and the OS where this will be written for is Vista (sorry - I might upgrade to W7 tho). Could someone give me some hints? Kind regards,

    C / C++ / MFC help debugging question

  • [Message Deleted]
    I iMikki

    Im not really looking to using vectors. Ah well I think I'll do it otherwise then :p Thanks anyhows!

    C / C++ / MFC

  • [Message Deleted]
    I iMikki

    This post can get deleted - I hoped to take the replies with it.

    modified on Wednesday, November 4, 2009 2:50 PM

    C / C++ / MFC

  • Converting data from TextBox (String^) to string
    I iMikki

    No Im not driving lol. It works! *cheering the hell outta it* Adding text to the TextBox and with a button its sending the data to my vector string which can be read and send to the output :-\ Thank you very very much! I really needed this line! <33 :rose:

    C / C++ / MFC help csharp visual-studio graphics tutorial

  • Converting data from TextBox (String^) to string
    I iMikki

    How strange - because I copied it directly from your post - since first of all I hate typing and secondly its always better to copy paste :p But it is working now - let me test the output etc. Thanks in advance <3

    C / C++ / MFC help csharp visual-studio graphics tutorial

  • Converting data from TextBox (String^) to string
    I iMikki

    1>d:\stageappvc\terminalapp\terminalapp\Form1.h(200) : error C2653: 'Marshel' : is not a class or namespace name
    1>d:\stageappvc\terminalapp\terminalapp\Form1.h(200) : error C2228: left of '.ToPointer' must have class/struct/union
    1> type is ''unknown-type''
    1>d:\stageappvc\terminalapp\terminalapp\Form1.h(200) : error C3861: 'StringToHGlobalAnsi': identifier not found

    Is there any other known way to get text out such TextBox into a string? One made by Microsoft themselves? :p

    C / C++ / MFC help csharp visual-studio graphics tutorial

  • Converting data from TextBox (String^) to string
    I iMikki

    #pragma once
    #include <iostream>
    #include <fstream>
    #include <vector>
    #include <string>
    //#include <Windows.h>

    namespace TerminalApp {

    using namespace std;
    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;
    
    /// <summary>
    /// Summary for Form1
    ///
    /// WARNING: If you change the name of this class, you will need to change the
    ///          'Resource File Name' property for the managed resource compiler tool
    ///          associated with all .resx files this class depends on.  Otherwise,
    ///          the designers will not be able to interact properly with localized
    ///          resources associated with this form.
    /// </summary>
    
    //Variabele waar alle code in komt te staan//
    std::vector<string> textCode;
    
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
    	Form1(void)
    	{
    		InitializeComponent();
    		//
    		//
    	}
    
    protected:
    	/// <summary>
    	/// Clean up any resources being used.
    	/// </summary>
    	~Form1()
    	{
    		if (components)
    		{
    			delete components;
    		}
    	}
    private: System::Windows::Forms::Button^  exitButton;
    private: System::Windows::Forms::Button^  addText;
    private: System::Windows::Forms::RichTextBox^  textBox;
    private: System::Windows::Forms::Button^  saveButton;
    private: System::Windows::Forms::TextBox^  invoerVeld;
    private: System::Windows::Forms::Button^  voegTextButton;
    
    
    private:
    	/// <summary>
    	/// Required designer variable.
    	/// </summary>
    	System::ComponentModel::Container ^components;
    

    #pragma region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    void InitializeComponent(void)
    {
    this->exitButton = (gcnew System::Windows::Forms::Button());
    this->addText = (gcnew System::Windows::Forms::Button());
    this->textBox = (gcnew System::Windows::Forms::RichTextBox());
    this->saveButton = (gcnew System::Windows::Forms::Button());
    this->invoerVeld = (gcnew System::Windows::Forms::TextBox());
    this->voegTextButton = (gcnew System::Windows::Forms::Button());
    this->SuspendLayout();
    //
    // exitButton
    //
    this->exitButton->Location = System

    C / C++ / MFC help csharp visual-studio graphics tutorial

  • Converting data from TextBox (String^) to string
    I iMikki

    1>d:\stageappvc\terminalapp\terminalapp\Form1.h(7) : fatal error C1083: Cannot open include file: 'Marshal': No such file or directory :p Yeh - I corrected it but copied the wrong stuff I saw... But with A its still not working :( I am using Visual C++ Express Edition. Downloaded the package yesterday :p

    C / C++ / MFC help csharp visual-studio graphics tutorial

  • Converting data from TextBox (String^) to string
    I iMikki

    I guess I need the second then. Currently I have

    std::string str1 = (const char*)(Marshel::StringToHGlobalAnsi(textBox->Text)).ToPointer();

    But it gives me the following errors:

    1>d:\stageappvc\terminalapp\terminalapp\Form1.h(200) : error C2653: 'Marshel' : is not a class or namespace name
    1>d:\stageappvc\terminalapp\terminalapp\Form1.h(200) : error C2228: left of '.ToPointer' must have class/struct/union
    1> type is ''unknown-type''
    1>d:\stageappvc\terminalapp\terminalapp\Form1.h(200) : error C3861: 'StringToHGlobalAnsi': identifier not found

    So I tried to #include , but that didn't work either. How can I use this function? And by the way - thanks for your fast replies :)

    C / C++ / MFC help csharp visual-studio graphics tutorial

  • Converting data from TextBox (String^) to string
    I iMikki

    I dont see the relation between the first line and the other two. And I need it otherwise. I have a String^ (coming from textBox->Text) and I want to store this in a string (which I have in a vector).

    C / C++ / MFC help csharp visual-studio graphics tutorial

  • Converting data from TextBox (String^) to string
    I iMikki

    I have: std::vector textCode; private: System::Windows::Forms::RichTextBox^ textBox; private: System::Windows::Forms::TextBox^ invoerVeld; textBox->Text += invoerVeld->Text + "\r\n"; < works fine textCode.push_back(textBox->Text); < no-go textCode.push_back(invoerVeld->Text); 1>d:\stageappvc\terminalapp\terminalapp\Form1.h(194) : error C2664: 'std::vector<_Ty>::push_back' : cannot convert parameter 1 from 'System::String ^' to 'const std::string &' 1>d:\stageappvc\terminalapp\terminalapp\Form1.h(195) : error C2664: 'std::vector<_Ty>::push_back' : cannot convert parameter 1 from 'System::String ^' to 'const std::string &' So I think I cannot just use string in stead of String. Its a native thing of the TextBox and RichTextBox. I guess... Or if Im wrong, correct me :)

    C / C++ / MFC help csharp visual-studio graphics tutorial

  • Converting data from TextBox (String^) to string
    I iMikki

    Hello people, I am trying to make an application with in- and output. Input by textboxes and output by writing it to a file. I succeeded to get text from a TextBox^ and put it in a RichTextBox^. No problem. I succeeded to use fstream to 'print' data (string) to a file. Now I want to combine these by using a vector. The problem I am facing is that if I do: fout << textBox->Text; that I get the following error:

    1< d:\stageappvc\terminalapp\terminalapp\Form1.h(185) : error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'System::String ^' (or there is no acceptable conversion)
    1< C:\Program Files\Microsoft Visual Studio 9.0\VC\include\ostream(653): could be 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const char *)

    If I want to write the

    textBox->Text

    to my vector. I get the following error:

    1>d:\stageappvc\terminalapp\terminalapp\Form1.h(194) : error C2664: 'std::vector<_Ty>::push_back' : cannot convert parameter 1 from 'System::String ^' to 'const std::string &'

    I tried to find out what this String^ actually is - but I could not find an accurate answer. I also tried:

    textBox->Text.toString()

    which failed too. Is anyone able to help me with this? I tried to find examples of how to put TextBox data in a string, but I couldn't find anything useful... Kind regards, Mikki Weesenaar

    C / C++ / MFC help csharp visual-studio graphics tutorial
  • Login

  • Don't have an account? Register

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