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
P

Peter Molnar

@Peter Molnar
About
Posts
191
Topics
24
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • avoid an application closing when calculations are in progress?
    P Peter Molnar

    This is a multithreading issue. 1.Spawn a worker thread with the the long calculation

    Thread m_Thread;
    ...
    m_Thread = new Thread(new ThreadStart(MyLongCalculationFunction));
    m_Thread.Start();

    2.In your Form_Closing handler check the thread state

    if (m_Thread.ThreadState == ThreadState.Running) ...

    If running, dont let the dialog close by giving

    e.Cancel = true;

    Peter Molnar

    C# help tutorial question

  • DataGrid Row Colours
    P Peter Molnar

    If you have a web form, override the ItemDataBound event. Peter Molnar

    C# question com design hosting tutorial

  • How do i read HTML files into a string like .txt files.
    P Peter Molnar

    1.Download the file. Look up for this HttpWebRequest, or WebClient in MSDN (WebClient is somewhat easier to use for the first time). If you dont know, also look up HTTP communication 2.Save the the downloaded string into a text file, look up IO e.g.: StreamWriter Peter Molnar

    C# question html

  • Down Arrow Key
    P Peter Molnar

    you should cast the Keys enum to int, so it will compile

    private void OnKeyPress(object sender, System.Windows.Forms.KeyEventArgs e)
    {

    if(e.KeyValue == (int)Keys.Down)
    {
    ...
    }
    }

    Peter Molnar

    C# tutorial

  • Down Arrow Key
    P Peter Molnar

    Override the KeyPress, KeyDown, or KeyUp event (as you need) in your form class, and check the KeyValue values of KeyEventArgs. Peter Molnar

    C# tutorial

  • Multithreading...
    P Peter Molnar

    Hello, I wanna write a multithreaded application and I am in need of a feature which is known to me in MFC, but I am unaware of in .NET. The problem is that I wanna spawn a worker thread from one of my forms. I can pass data to my worker thread from my dialog, but it is not enough to me, I also have to manipulate the UI controls of the caller from my worker thread. In MFC one can pass a pointer of the caller dialog to one's worker thread, which does the job. I am sure, there must be a similar thing in .NET too. Please help! Thanks in advance. Peter Molnar

    C# help csharp c++ design career

  • ADO.NET
    P Peter Molnar

    Hello, I am new to ASP.NET, therefore I have a simple question: I want to read and update an existing row in my database with some new information. I have no problem with reading but very much problem with updating. I tried the below code, and I get a runtime error: System.Data.OleDb.OleDbException: Operation must use an updateable query. in the line: myAdapter.Update(myDataSet,"Tasks"); If I try UPDATE instead of SELECT in the SQL statement then I get: System.Data.OleDb.OleDbException: Syntax error in UPDATE statement. in the line: myAdapter.Fill(myDataSet,"Tasks"); This my code:

    OleDbConnection myConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;"
    +"Data Source=c:\\data.mdb");

    myConnection.Open();

    OleDbDataAdapter myAdapter = new OleDbDataAdapter("SELECT * FROM Tasks",myConnection);

    OleDbCommandBuilder myBuild = new OleDbCommandBuilder(myAdapter);

    DataSet myDataSet = new DataSet();

    myAdapter.Fill(myDataSet,"Tasks");

    TextBox1.Text = String.Format("{0}", myDataSet.Tables["Tasks"].Rows[0]["Number"]);
    myDataSet.Tables["Tasks"].Rows[0]["Company"] = "Text"; //This is where I update the DataSet

    myAdapter.Update(myDataSet,"Tasks");
    myConnection.Close();

    Peter Molnar

    ASP.NET database help csharp asp-net question

  • How to access Cell Phone (ie: Nokia) via Irda from PC ?
    P Peter Molnar

    HI, IrDA really implements a VIRTUAL serial port by means of its device driver, and it is also the device driver which is responsible for the device to be recognized by the OS, and XP has definitely more built-in drivers than previous OSs. Virtual means that an IrDA device can really be manipulated like a real COM port although it is not. Since I dont have any real experience specifically with IrDA I suggest you to consult the device manufacturer's documentation. Peter Molnar

    C / C++ / MFC c++ tutorial question

  • How to access Cell Phone (ie: Nokia) via Irda from PC ?
    P Peter Molnar

    Hi Ivan, sorry for not answering for a long time but I was away from my desk. As for porting C++ code to VB.NET, I am not familiar it but I definetaly know -just as you write- that it is possible to call Win32 API functions from VB.NET code. Comments on your code: 1.The first param of CreateFile is a string like "COM1" or any other string describing the communication device's name. Inspite of the function name NO file is actually created. Use GENERIC_READ | GENERIC_WRITE access flags. 2.CreateFile returns a handle which identifies the opened communication port. Using this handle you can call WriteFile to send AT commands to the device and later on ReadFile to check for response. 3.In order to not block your channel forever, and receive your info you should poll the port for answer (of course only after you have successfully sent to it an AT command) in a loop with ReadFile for a pre-defined, device specific period of time. You should collect the returned info in a buffer. 4.A successfully opened device that you communicate with ALWAYS returns a response regardless of whether the given AT command is understood by the device or not. Possible responses are "\r\nERROR\r\n" if the AT command is not known to the device, or "\r\nSOME INFORMATION\r\n\r\nOK\r\n" if the sent AT command is supported, where \r\n is 0x0d and 0x0a. Peter Molnar

    C / C++ / MFC c++ tutorial question

  • pointers to doc class from other classes
    P Peter Molnar

    Do the following: 1.Add a member variable to your app class

    CYourDoc* m_pYourDoc;

    2.Add a memeber function to your app class:

    SetYourDoc(CYourDoc* pYourDoc)
    {
    m_pYourDoc = pYourDoc;
    }

    3.In your doc class' constructor call

    theApp.SetYourDoc(this);

    Peter Molnar

    C / C++ / MFC question help tutorial learning

  • Browser Helper Object : How to stop form being submitted
    P Peter Molnar

    As Terry has already pointed out, an event signalizes in this case that something has already taken place, and you cannot influence the trigger of the event in the past. However there is a workaround, and it is called API hooking/hijacking/monitoring. Internet Explorer uses the Wininet functions to communicate with the internet. If your user clickes the "go" button with some url in the address bar, the appropriate Wininet functions, like HttpOpenRequest and HttpSendRequest are called inside IE's code. The same applies to when the user submit a form. If you hook into the WinInet functions from your BHO, then you will be able to monitor and "authorize" IE's actions. Example: if your user clicked a Submit button on a form with POST action then HttpOpenRequest is called with the second parameter lpszVerb being "POST". You can take any action including stopping the process. If a form with "GET" action is concerned, your job is a bit more difficult because the verb in this case does not differ from "ordinary" page requests. You could then take into account the url from your form, and compare it with lpszObjName (3. param of HttpOpenRequest) If you are unfamiliar with API hooking, check out this article: http://www.codeproject.com/useritems/api_monitoring_unleashed.asp Peter Molnar

    C / C++ / MFC html sysadmin help tutorial

  • Hardware Interfacing
    P Peter Molnar

    You can get Caller indentification info from LINECALLINFO struct, look up TAPI in MSDN Peter Molnar

    C / C++ / MFC hardware architecture help

  • Automated Windows testing tools...???
    P Peter Molnar

    check out this excellent and FREE tool: http://www.codeproject.com/dll/eventrecorder.asp Peter Molnar

    C / C++ / MFC question ai-testing testing beta-testing tools

  • How to access Cell Phone (ie: Nokia) via Irda from PC ?
    P Peter Molnar

    Communication between the phone and the PC can be established in the following ways: 1.RS232 serial port 2.IrDA 3.Bluetooth Whether you believe or not all three ways work the same way, namely by sending so called AT commands to the phone and receiving an answer. I would recommend you to look up Device I/O in the PlatformSDK, especially functions like ReadFile and CreateFile,WriteFile, and ReadFile (yes, they are called file!). they will tell you have to communicate over the serial port. You can use the same functions for communicating over IrDa and Bluetooth, because both implement an RS232 serial interface. From the point of view of your code, the only difference is that you use the device's name when opening them with CreateFile (e.g. IRDAx or BTHx instead of COMx). Peter Molnar

    C / C++ / MFC c++ tutorial question

  • CComObject<> Problem
    P Peter Molnar

    You have very much to call CreateInstance, which I ment to indicate with ... (dots) in my code. Since it was OK in yours, I didn' repeated it again, modify your get_Connection function accordingly. AddRef tells the object that there will be one more call on it, it should not unload itself, and Release tells that the call have already taken place, it can unload. So after you received the interface pointer,you should release it. Smart pointers indeed eliminate this, because they call AddRef on object creation and Release on when the object goes out of scope. Peter Molnar

    C / C++ / MFC help question com sysadmin

  • Shell ?
    P Peter Molnar

    Hi Marty, glad to see you again. You can prorammatically switch on Autocheck property, and also easily decrease its interval to e.g. 0.1s (after first retreaval you can switch it off) 1.Get the GUID value of HKCU\Identities\Default User ID 2.Set HKEY_CURRENT_USER\Identities\{GUID}\Software\Microsoft\Outlook Express\{...version...}\Poll For Mail to desired intervall in millisec 3.Set HKEY_CURRENT_USER\Identities\{GUID}\Software\Microsoft\Outlook Express\{...version...}\Dial during Poll to 2 for switching off 1 for connecting when offline 0 for connecting when online Peter Molnar

    C / C++ / MFC linux question

  • CComObject<> Problem
    P Peter Molnar

    1.Initialize your object

    CComObject<CYourBaseClass>* pConnection;
    ...
    pConnection->AddRef();
    return pConnections;

    2.Returning a pointer cuases very much a memory leak UNLESS you destroy it in your caller function

    CComObject *pConnection = GetGroupConnections(...);
    pConnection->...
    pConnection->Release();

    Peter Molnar

    C / C++ / MFC help question com sysadmin

  • What is needed for programming a VC project about WMA audio format?
    P Peter Molnar

    Take a look at the Windows Multimedia library of the PlatformSDK, functions like waveInStart, waveInStop, waveOutOpen , waveOutClose Peter Molnar

    C / C++ / MFC question

  • saving private processor
    P Peter Molnar

    It is not advisable to have a lenghty operation like yours within the UI thread because it gets blocked. Look up worker threads in MSDN. Peter Molnar

    C / C++ / MFC c++ css help question

  • My DllMain is not getting invoked.
    P Peter Molnar

    I have created a small project which contains 4 lines of code:

    #include <windows.h>
    BOOL DllMain(HINSTANCE , DWORD , LPVOID )
    {
    ::MessageBox(NULL,"test","Caption",MB_OK);
    return TRUE;
    }

    and call it

    HINSTANCE hInstance = LoadLibrary("pathto.dll");

    works just fine. Try the same. What is hInstance when you debug? Peter Molnar

    C / C++ / MFC tools 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