pseudorandom21 166 Practically a Posting Shark

I think you will have to use a stream manipulator for that, I forget which one, maybe std::ios::fixed or std::ios::setprecision. They're in <iomanip>.

http://www.cplusplus.com/reference/iostream/manipulators/

You can set the output stream to display leading zeroes, but my question is why do you want the zero to be shown?

pseudorandom21 166 Practically a Posting Shark

I actually wrote some code to show you one way to do it.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)
{
	using namespace System::Diagnostics;
	String ^notepad_path = "C:\\Windows\\System32\\notepad.exe";//<-- path to .exe
	ProcessStartInfo ^notepad_procinfo = gcnew ProcessStartInfo(notepad_path);//<-- process start info,
	//^^ required to associate an instance of the process class with the process it creates.
	Process ^notepad_proc = gcnew Process();//<-- Process class instance.
	
	notepad_proc->StartInfo = notepad_procinfo;//<-- Set this property to the notepad_procinfo.

	if(notepad_proc->Start())//<-- parameterless start method called, it uses the previously established ProcessStartInfo
		//^^ This method is NOT static, unlike the version you were previously using.  This version is unique to the class instance.
	{
		Console::WriteLine("Notepad running.");
	}
	else
	{
		Console::WriteLine("PROCESS CREATION FAILED!");
		return 1;
	}
	while( !notepad_proc->HasExited )
	{
		Console::WriteLine("Still running...");
		Threading::Thread::Sleep(1000);
	}
    return 0;
}

Honestly, if you had read the links I have given you, I think you could have done this. If not, then learn a bit so you aren't asking someone for code. Problem solving is a part of programming, you know?

pseudorandom21 166 Practically a Posting Shark

Now you've confused me, would you please clarify if your application starts the process or not?

pseudorandom21 166 Practically a Posting Shark

Oh ok, so did you use the "Process" class to start the process?
Process Class: http://msdn.microsoft.com/en-us/library/ccf1tfx0.aspx

If so, then this property will be what you want to check: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.hasexited.aspx

Alternatively, you may want to use this event: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.exited.aspx

Honestly It's best if you take your pick, because there is more than one way to do it. So, do some research for a managed solution to the problem: http://msdn.microsoft.com/en-us/library/ccf1tfx0.aspx
then decide what you want to do, and give it a try.

pseudorandom21 166 Practically a Posting Shark

Won't compile or won't link?

pseudorandom21 166 Practically a Posting Shark

As for solving the problem, my idea is to enumerate the running processes, and search for ones named "notepad", and ones with a path to the executable that point to the location of "notepad.exe", and if required (normally it probably would be, otherwise this faulty mechanism for detecting if notepad is open won't always work), I would attempt to compare checksums of running executables to a list of checksums for "notepad.exe", depending on which Windows version you are running the checksum may be different.

Now, that raises the question what if the user is running another text editor? Should that also be detected? I think the entire idea is faulty, or maybe I just don't have a database of checksums for known text editors.

In the end, the problem is yours to solve, unless you intend to pay someone else to do it for you.

If you do manage to find a very elegant managed solution to the problem, then please do tell.

This solution seems to be highly dependent upon the requirements.

pseudorandom21 166 Practically a Posting Shark

You can use the Windows API with C++/CLI normally, unless you intend to consume functions/classes that are purely native code with other .NET languages, in which case you will need a managed wrapper around the pure native functions/classes to use them with other .NET languages.

If your project will only use C++ or C++/CLI & C++ then it is my guess you can use the Windows API functions with no problem.

There may be a managed solution to this problem, but I am unaware of the details of it. By all means feel free to research a managed solution to this problem on MSDN.

pseudorandom21 166 Practically a Posting Shark

If you're using Windows...
Research some Windows API functions. If memory serves me, you'll want to enumerate the processes then it may be required that you get the path to the executable.

http://msdn.microsoft.com/en-us/library/ms682623%28v=vs.85%29.aspx

pseudorandom21 166 Practically a Posting Shark

Assuming you can get your input into a string...

//Caleb Taylor 2011
//This is one way to do it.
#include <iostream>
#include <string>
#include <cctype>

int main()
{
  using namespace std;
  string input = "I want this on a banner.";
  unsigned int count = 0;
  for(string::iterator it = input.begin(); it != input.end(); ++it)
  {
    if( !isspace(*it) )
      count++;
  }
  cout << count << endl;
}

I would think by index of a simple array would be just as easy.

pseudorandom21 166 Practically a Posting Shark

I appreciate the response, but I need to wait until tomorrow to give it a try--which I will, and I'll post the result.

pseudorandom21 166 Practically a Posting Shark

C++/CLI @ runtime add a PictureBox to a tab control, I need to do this at run-time because they're to represent some data the user must be able to manipulate. I actually need them to be in some kind of scrollable panel on the tabcontrol. Any ideas?

pseudorandom21 166 Practically a Posting Shark

Hmm, well..
here you can assign a name to a function pointer...

typedef void (*someFunc)(int param);
someFunc func_pointer = nullptr;
pseudorandom21 166 Practically a Posting Shark

If I'm not mistaken .at() will throw an exception if the programmer tries to access an element beyond the bounds of the array--while operator[] will not.

Consequently, .at() may be less efficient (so I've heard).

pseudorandom21 166 Practically a Posting Shark

Also, the functions in <cctype> may be helpful.
particularly isspace() and isalnum().
#include <cctype>

pseudorandom21 166 Practically a Posting Shark

Might have to write a driver or a mini driver.

If you're using Windows check out the DDK (Driver Development Kit). For devices like a mouse often only a mini-driver is required.

pseudorandom21 166 Practically a Posting Shark

You can use a bitset to set your bits as needed.
see here: http://www.cplusplus.com/reference/stl/bitset/

Otherwise, I'm afraid I'm not a libusb expert, nor in working with USB.

I don't know if you want to send a 0 then a 1 in separate calls to the right function or send say an integer with bits set from a bitset.

pseudorandom21 166 Practically a Posting Shark

Ok actually I solved it, there IS a difference between:

Invoke( someDelegate );

and:

someDelegate->Invoke();

Invoke(someDelegate); will do exactly what I needed. :)

pseudorandom21 166 Practically a Posting Shark

This may be helpful for you (Windows only): http://msdn.microsoft.com/en-us/library/ms810467.aspx

This may also be helpful: http://www.libusb.org/

seoforpakistan commented: How to use php as data base? +0
pseudorandom21 166 Practically a Posting Shark

Hello, I thought I was doing things right when I created a delegate to call a function to access the container's data, but it still throws an exception.

I have something similar to:

public ref class myform : public System::Windows::Forms::Form
{
  private: System::Windows::Forms::ComboBox^  form_combobox;
  private: delegate String^ getItemDel();//<-- delegate

  private: String^ GetComboboxSelectedItem(){  //<-- function I call with a delegate.
  return form_combobox->SelectedItem->ToString();
  }

  private: Thread ^work_thread;//<-- used to run DoWork() in a new thread.
  private: void DoWork() { //<-- worker function that accesses the combobox data.
  //access container's data.
  getItemDel ^f = gcnew getItemDel(this, &myform::GetComboboxSelectedItem);
  String ^result = f->Invoke();//<-- ** problem **
  }
};

Sorry, I've done my best to condense it. I thought that was the accepted way to access the data, I must be mistaken.

It throws an exception saying I'm not supposed to access the container's data from a different thread.

pseudorandom21 166 Practically a Posting Shark

Yes that is correct, ancient dragon.

pseudorandom21 166 Practically a Posting Shark

You will have to maintain an array of account numbers. In certain circumstances a programming teacher may accept a statically allocated array--when learning the basics of programming.

If you don't know how to use arrays, I suggest you learn how. Truthfully there are (probably) infinite ways to accomplish the task, however.

pseudorandom21 166 Practically a Posting Shark

Using C++/CLI--
Is there a good way to return a value (not a DialogResult) from a form shown as a dialog?

I plan to use Invoke on a method to update the previous form from within the dialog, if not.

I also would like to thank the fine members of Daniweb for being so helpful, as always.

pseudorandom21 166 Practically a Posting Shark

Wow, thanks.

pseudorandom21 166 Practically a Posting Shark

For some reason, and it's probably one of those accessibility things like tab ordering, when I hit the spacebar after selecting a button on my form, the spacebar clicks the button.

This is NOT acceptable, and I have considered a work around of selecting an invisible panel or other "dummy" control after clicking any button on the form.

I'm wondering if there is any other way?

pseudorandom21 166 Practically a Posting Shark

Compile it. My guess is the compiler won't automatically cast the address of that pointer to an integer value.

pseudorandom21 166 Practically a Posting Shark

Hi, I am in need of a good reference for C++/CLI. Right now I need to know how to exit the main loop of a form, such as if the user clicked the 'X' at the top right.

Nevermind, the function Close() is what I needed.

pseudorandom21 166 Practically a Posting Shark

The code for templates must be only in a header file.

Which isn't exactly true, the other way is to include the .cpp file at the bottom of the .h

when doing that with visual studio you must also exclude the .cpp file from the solution explorer. Easiest/best to just include the code in the header file.

If you do that wrong you get link errors.

pseudorandom21 166 Practically a Posting Shark

you can also use toupper() or tolower() in <cctype>
or use the falling-through behavior of the switch for 'Y' and 'y' etc.

Though, personally I would make a small function to test if it was valid.

pseudorandom21 166 Practically a Posting Shark

didn't know that. thanks.

pseudorandom21 166 Practically a Posting Shark

I forgot to mention it also uses the boost library.
It doesn't build, it spouts errors about the boost library code like this:

1>c:\boost_1_45_0\boost\thread\win32\thread_primitives.hpp(314): warning C4793: 'boost::detail::win32::interlocked_bit_test_and_set' : function compiled as native :
1> Found an intrinsic not supported in managed code

When compiled with CLR support.

I'm assuming that's required? It builds fine without CLR support.

pseudorandom21 166 Practically a Posting Shark

Due on Sunday night? Tomorrow is Martin Luther King Jr. Day here too...

pseudorandom21 166 Practically a Posting Shark

Yes, you can get your input into a string and parse it.

#include <string>
#include <sstream>
#include <iostream>
using namespace std;

int main()
{
  string input;
  getline(cin,input);
  int value = 0;
  stringstream(input) >> value;
  if(value == 0)
     cout << "Invalid entry." << endl;
  cout << value << endl;
}
pseudorandom21 166 Practically a Posting Shark

May have to dynamically allocate the memory using "new" and "delete".

Also, in this line:

int fileTempSize = data.size();

int doesn't have the range of the unsigned int, make sure your fileTempSize is the same type as the type returned by data.size()

this can cause problems if the size is greater than std::numeric_limits<int>::max(), it will overflow the variable.

std::vector<char>::size_type fileTempSize = data.size();

Or if you have a compiler that supports the new "auto" keyword..

auto fileTempSize = data.size();
pseudorandom21 166 Practically a Posting Shark

1. int a[ ][ ] ={{2,3},{3,4},{4,5}};
i. It will create a 3*2 matrix and initialize it
1. 2.
1. [ [2][3] ] //<-- one way to think about it.
2. [ [3][4] ] //3 x 2
3. [ [4][5] ]

pseudorandom21 166 Practically a Posting Shark

Hello, I'm hoping you can help me make a smart decision. I have some code written in native C++, a full program actually--and I need to use it with C#. The application is, at the moment, very basic. It has a console user interface, and settings need to be changed via changing some code (no user interface). I've read there are at least two ways to do this, one of which is using C++/CLI and the other being creating a DLL.

The native C++ prog. makes extensive use of classes, multi-threading, and the typical things in a C++ program.

Which option would be the best (least work) for using the code in C# ? Keep in mind, I've not had much experience with creating DLL's nor with using C++/CLI.

I will appreciate any advice or opinions you may have, thank you.