nmaillet 97 Posting Whiz in Training

Could be a video card issue. Given that it's 10 years old, I would say it's time for a new laptop, but you could always try updating the video card drivers or formatting and reinstalling Windows (not Windows Vista/7, I assume?).

nmaillet 97 Posting Whiz in Training

...I don't even know where to begin on that, but here we go:

The .NET framework is a platform on which applications developed using microsoft tools run on.

Kind of, but MonoDevelop is used to run .NET code on several platforms. Unless you consider the language syntax and specification tools.Console C++ programs can run without the .NET framework

Console C++ programs can run without the .NET framework

What's your point? You can write console C++ applications with or without the .NET Framework. Same for GUI applications and static/dynamic libraries.

but when the framework is there, it does not make any difference

That makes a huge difference. You suddenly have access to the .NET Framework, which has a massive library of classes and has a garbage collector. Also, you can have a mixture of managed and unmanaged code. Along with some decrease in performance, given the overhead of the garbage collector and the interpreter. That's a pretty significant difference I would say.

C++ language is also included in the Microsoft Visual Studio suit

Yup.

I'm sure just to make it easily accessible by C++ lovers and to add a graphical touch to it.

I'll admit, this is somewhat correct, although lacking quite a bit. The whole purpose of an IDE is to give a set of tools to aid in the development of applications, along with a "graphical touch". Without it, we're back to using a text editor and the command …

nmaillet 97 Posting Whiz in Training

What tool are you using to interact with the database file? If you are using something like the entity framework, data gets cached in memory, but doesn't get written out to disk until you explicetly tell it to. Your app could still see it since it's in the cache.

As far as MDI goes, I believe support is disappearing for it. If you are dead set on using it, you can change the Form.IsMdiContainer to true (take a look here).

If you just want to get rid of the taskbar button for your child windows, set the Form.ShowInTaskbar to false, see here.

Btw, I'm assuming you're using WinForms, since that's what I see on these forums, for the most part, and you didn't specify. If you're using WPF, let me know.

nmaillet 97 Posting Whiz in Training

I'm trying to create some custom styles/control templates for WPF. The only control that seems to be giving be any issues (so far) is the ScrollViewer:

    <Style x:Key="{x:Type ScrollViewer}" TargetType="ScrollViewer">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ScrollViewer">
                    <Border Background="#404040">
                        <Border BorderBrush="#808080" BorderThickness="1" Margin="4">
                            <Grid >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>

                                <ScrollContentPresenter Name="PART_ScrollContentPresenter"/>
                                <ScrollBar Grid.Column="1"
                                   Name="PART_VerticalScrollBar"
                                   Orientation="Vertical"
                                   Value="{TemplateBinding VerticalOffset}"
                                   Maximum="{TemplateBinding ScrollableHeight}"
                                   ViewportSize="{TemplateBinding ViewportHeight}"
                                   Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"/>
                                <ScrollBar Grid.Row="1"
                                   Name="PART_HorizontalScrollBar"
                                   Orientation="Horizontal"
                                   Value="{TemplateBinding HorizontalOffset}"
                                   Maximum="{TemplateBinding ScrollableWidth}"
                                   ViewportSize="{TemplateBinding ViewportWidth}"
                                   Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"/>
                            </Grid>
                        </Border>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

When I add a ListBox, and ~70 items (just ListBoxItems with string Content) it gives me some wierd scrolling issues. When I click and hold it scrolls down as it should. When I click and hold (while scrolled towards the bottom) and move the cursor up, the list jumps up and after moving a few pixels reaches the top of the list.

I commented every other style I was using and it still gives me the same result. When I disable the ScrollViewer style, everything works fine. I even tried copying the example custom style from the MSDN library here. It has the same issue. I thought it might be a property that gets set by the default style, so I removed the OverridesDefaultStyle setter, and no luck. It was being used as a merged resource dictionary from another project, so I moved it to the windows resource collection. I think I'm out of ideas now...

nmaillet 97 Posting Whiz in Training

This should probably be in the WebDev section, but without seeing any examples, I don't think anyone be able (or atleast willing) to try helping. The layout and rendering of webpages is handled quite differently depending on the browser. That's one of the many reasons I've been avoiding any major web development projects.

nmaillet 97 Posting Whiz in Training

You could use the WinAPI for this. Take a look at my previous post here.

nmaillet 97 Posting Whiz in Training

Give this a try:

        SqlDataAdapter dt = new SqlDataAdapter();
        SqlCommand command = new SqlCommand("select * from DVD where Name = @name", c);
        command.Parameters.Add("@name", SqlDbType.VarChar, 100).Value = txtName.Text;
        dt.SelectCommand = command;

Couple of things, first it should handle any encoding issues or data type mismatches since the parameter is defined (double check and make sure Name is varchar(100)). Secondly it should prevent SQL injections, according to this article. I haven't tested it out myself, but you may want to look into SQL injections if anybody else is going to be using this.

nmaillet 97 Posting Whiz in Training

There are good reasons for not using these functions. They're fine as a learning excercise for the original poster, but they're nowhere near production quality. QuadraticFomula crashes if a is zero, AbsoluteValue has an unneccesary multiplication (which the optimizer might replace) and involves unnecessary coercions if called with anything but a float. NthRoot is an inefficient way of doing what Math.Pow could do for itself (and crashes for Index==0), the SquareRoot algorithm is inefficient, and so on. The solution to beginners not knowing about the Math class in C# is to point them to the Math class, not to reinvent an inferior version.

I agree. Another thing I would like to point out, there are far too many unnecessary function calls. For instance:

public static float Square(float Value) { return Value * Value; }
public static float Cube(float Value) { return Square(Value) * Value; }

Is it really necessary to add the extra overhead of a function call when you could simply write Value * Value * Value? I do realize that the compiler will likely, with optimizations enabled, remove these calls, but when the term game development is used, it makes me think of an attempt at efficiency. While I'm on this though, I think the worst offender is:

public static float CubedSquared_Divided(float Value) { return Cube(Value) / Square(Value); }

That is 3 function calls, 1 division and some multiplication operations that could simply be replaced with:

public static float CubedSquared_Divided(float Value) …
nmaillet 97 Posting Whiz in Training

For what?

nmaillet 97 Posting Whiz in Training

You want to have a look at this thread. I don't have time to look at the solutions now, but they may be of some help.

nmaillet 97 Posting Whiz in Training

Why don't you post the entire error message? And some code? You generally do it like this:

cmb.removeAllItems();
cmb.addItem("item 1");
cmb.addItem("item 2");
...

If there's a change of having duplicate strings, create a class and override the toString() method, or use anonymous classes, like:

cmb.removeAllItems();
cmb.addItem(new Object() { public String toString() { return "item 1"; } });
cmb.addItem(new Object() { public String toString() { return "item 2"; } });
...
nmaillet 97 Posting Whiz in Training

On the same LAN? Can you connect via your browser? What port is it using?

nmaillet 97 Posting Whiz in Training

Where is the server located in relation to your dev machine? On the same machine? Same LAN?

nmaillet 97 Posting Whiz in Training

Inverse tangent, as in: arctan((eY-bY)/(eX-bX)). One other thing, you should do a check for the case when eX-bX returns 0. In this case, you would directly set the angle to 90 (or pi/2), or whatever the angle straight up is if 0 degrees isn't horizontal.

nmaillet 97 Posting Whiz in Training

You'll need to install Visual Studio Tools for Office (VSTO), which may have been installed with Visual Studio. The right-click on References and click Add References.... Use the .NET tab and add Microsoft.Office.Interop.Excel, but make sure you are using the correct version (eg. 11.0.0.0 for Office 2003, 12.0.0.0 for 2007 etc. (I think...)). Then you can start using it:

using Excel = Microsoft.Office.Interop.Excel;

...

Excel.Application app = new Excel.Application();
Excel.Workbook book = app.Workbooks.Open("c:\\my_template.xls", ReadOnly: true);
Excel.Worksheet sheet = book.Worksheets[0];

...

You'll have to read up a bit on the Office API. Couple things though:

  • The user must have the same version of Office installed.
  • VS2008 supports Office 2003/2007; VS2010 supports Office 2007/2010 etc (although you can work around that).

There are also project templates that correspond to the above versions, however I've never had a chance to use them (we're stuck at Office 2003 Standard...). If you have any specific questions, I can try to answer them.

P.S. For Office 2007/2010 workbooks (i.e. XLSX) you can unzip them and work with XML files if you like. Microsoft did release the references for those file types.

nmaillet 97 Posting Whiz in Training

The value you pass into SetAngle is:

tan(angle) = (eY / pixelsPerMeter-bY / pixelsPerMeter)/(eX / pixelsPerMeter-bX / pixelsPerMeter)

So, to get the angle (unless SetAngle for some reason accepted the tangent of the angle) you'd have to take the inverse tangent. Btw, that function can be reduced:

(eY / pixelsPerMeter-bY / pixelsPerMeter)/(eX / pixelsPerMeter-bX / pixelsPerMeter)
=[(eY - bY) / pixelsPerMeter]/[(eX - bX) / pixelsPerMeter]
=(eY - bY) / (eX - bX)

We're looking for a ratio instead of a measurement, so scale shouldn't matter.

nmaillet 97 Posting Whiz in Training

May I ask why? If you just need portability you could try compiling it with MonoDevelop (supports Linux, Mac OSX and Windows). Never really used it personally though...

nmaillet 97 Posting Whiz in Training

I don't know what you mean by DC... but are you working with 97-2003 documents or 2007-2010 documents? If you are using the older versions, you'll probably have to do some type of OLE automation, check here to get started (depending on what libraries you are using for your GUI it may be different). If you are using the newer file formats, they are an open standard and are basically a zip file of xml. Then you may need to encode the image in the format you want Word to use. Plently of libraries available for that.

nmaillet 97 Posting Whiz in Training

I might take some grief for this, but I would recommend you start out with RPG Maker (if it's still in existance) or GameMaker. RPG Maker does not specifically allow coding (atleast back in 2000) but does have procedural algorithms, and does somewhat introduce OO design. I would recommend GameMaker moreso. It allows programming in its proprietary C-style langauge, and is very OO by design (and also allows referencing external libraries written in other languages). You may even want to consider C# and the XNA Framework which relatively easy to pick up on.

The problem with using low-level languages, for beginners, is that it takes away from the fundementals of game design, and you spend too much time focused on programming language semantics.

nmaillet 97 Posting Whiz in Training

Could you be a little less vague? I don't think this is quite as simple as you think it is. What's the device? Does it have drivers? Is there an API? What video/audio encoding does it use? What are you doing with the video?

There is no one solution for this. It is depedent on many factors, some of which I listed...

nmaillet 97 Posting Whiz in Training

Could you be more specific? What does the exception say? What line of code is it referring too? etc...

Also, if you want to be sure isChecked is being correct set, add using System.Diagnostics then add Debug.WriteLine(isChecked); (if you are using an IDE that supports it). You can add some more information so the output is more meaningful, and shows which specific rows it is correctly getting isChecked from.

nmaillet 97 Posting Whiz in Training

Quoted Text Here

I could be completely wrong here as not tried any of code only looked at it,

But shouldn't ((CheckBox)row.FindControl("chkTypes")).Checked;

Be (CheckBox)(row.FindControl("chkTypes")).Checked;

So that is casts the object found as a CheckBox and not the row?

No. The dot operator takes precedence over the cast operator. If you did it that way, first of all, it would fail since Control does not have a Checked property. But, it would attempt to cast the Checked property to a CheckBox.

nmaillet 97 Posting Whiz in Training

The Conent property only supports one visual element. If you want to add another, you'll need to use a Panel, such as a Grid, Canvas, DockPanel or just about anything else that dervies from the Panel class. Assuming you are using XAML (if not, you should) it would look something like this:

<Window x:Class="Namespace.MainWindow">
    <Grid x:Name="myGrid">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </RowDefinition>
        <HeaderControl .../>
    </Grid>
</Window>

If you then accessed it from within the MainWindow (or whatever yours is called), you could do something like:

Grid.SetRow(fileuploadobject, 1);
myGrid.Children.Add(fileuploadobject);

If it's not within the class, you could either cast the instance of the Window to MainWindow and set the access modifier for myGrid to public, or cast the Content property to a Grid.

Btw, I'm a desktop developper, so the control types you may use could differ if you are using Silverlight, but the idea should be the same.

nmaillet 97 Posting Whiz in Training

3D modeling/animating I assume? Blender is an excellent open source tool. I wouldn't shell out money for the commercial software, unless your serious about it ($3,000+ for the popular ones). As for tutorials, Blender Guru and CG Cookie are good places to start... or just Google it...

nmaillet 97 Posting Whiz in Training

Here's the developer page for the Google Maps API, here. As far as I know, you can only request static images using the HTTP classes provided by the .NET Framework. If you want an full interactive map, you'll likely need to use the JavaScript API. You could possibly host it in a WebBrowser control: WinForms or WPF. I haven't used those controls very much, so I'm not sure how easy it is to interact between the control and your code.

Couple of things though, unless you are willing to pay: you can only request 1,000 static images per day (could be more if you verify your identity I think) and their are a few license restrictions (your app must be freely available, cannot be solely for internal use, etc.).

Good luck.

nmaillet 97 Posting Whiz in Training

Lerner got to it first.

nmaillet 97 Posting Whiz in Training

Is it just one Window that is doing this, or all? If it is just one, you could try removing everything from the XAML file (keep a copy somewhere else of course) and re-add everything piece by piece to see when the error arises. I remember getting something similar, but I can't remember what the exact exception was, or how I resolved it...

nmaillet 97 Posting Whiz in Training

Do you use a comma or a point as decimal separator? .NET prefers a point.

Not necessarily, I believe .NET uses the system's regional settings to determine this, unless specific IFormatProvider is used. Here they refer to the decimal point as culture-specific.

nmaillet 97 Posting Whiz in Training

If you look at the documentation (assuming UserControl is your base class):

The Load event occurs when the handle for the UserControl is created. In some circumstances, this can cause the Load event to occur more than one time.

In WinForms, controls are essentially wrappers for lower level classes. For example, you instantiate a TextBox in .NET. This reserves some memory for that class. At some point, before the control is shown, it creates a handle for a control (like you would do if you used the Windows API). This handle is used by low-level functions to display and query the control. Because programmers are not inherently efficient, the .NET framework is designed to make up for any lacking in efficiency. There is no need to create that handle right away. A programmer may instantiate a control class, but never use it, therefore it waits. It may also release the handle when a control is removed from a Form, and recreate it later when it is used again. If you want something to execute when the class is instantiated, put it in the constructor.

Essentially, this is lazy loading like thines01 said.

nmaillet 97 Posting Whiz in Training

What input was in the TextBox when this error occurred? You should wrap that if statement in a try-catch block in case the input is incorrect. Remember, an empty string or number with spaces may throw an error.

nmaillet 97 Posting Whiz in Training

Please use CODE tags when posting. textBox1 would return a reference to the actual TextBox. textBox1.Text would return the string displayed in the TextBox.

nmaillet 97 Posting Whiz in Training

Like skatamatic said, the share name for the C:\ drive on the remote machine will not be C: (it is probably something like C$ or C). Check the remote machine to ensure it is sharing the C:\ drive, what its share name is, and the permissions (right-click -> properties -> sharing etc.). Also, you need 2 backslashes in front of a network address, since \\ is an escape character you could either do:

string dirAddress = "\\\\192.168.15.96\\C$\\FTPTrace\\" + ipHeader.DestinationAddress.ToString() + ".txt";

or:

string dirAddress = @"\\192.168.15.96\C$\FTPTrace\" + ipHeader.DestinationAddress.ToString() + ".txt";
nmaillet 97 Posting Whiz in Training
StringBuilder builder = new StringBuilder(arraySeq[0].ToString());

Apologies, replace line 3 with the line above. I referenced the array instead of the first element.

nmaillet 97 Posting Whiz in Training

I copied your code exactly, and it seems to be working perfectly fine. I created a main method to access it, using a file containing your sample data:

#include <iostream>
#include <fstream>

using namespace std;

const int MAX_SIZE = 10;

void readToArray(int intArray[], ifstream &inFile);

void main () {
	ifstream file = ifstream("C:\\test.txt");

	int intArray[MAX_SIZE];
	
	readToArray(intArray, file);

	for(int i = 0; i < MAX_SIZE; i++)
		cout << intArray[i] << endl;

	system("pause");
}

void readToArray(int intArray[], ifstream& inFile)
{
  int i;
  for(i = 0; i < MAX_SIZE; i++)
    {
      inFile >> intArray[i];
    }
}

There must be something else going on. Are you getting a compile-time error? What is it? You may need to post more of your source code...

nmaillet 97 Posting Whiz in Training

For-loop?

if(arraySeq.Length > 0)
{
    StringBuilder builder = new StringBuilder(arraySeq.ToString());
    for(int i = 0; i < arraySeq.Length; i++)
        builder.Append(", ").Append(arraySeq[i]);
    textBox3.Text = builder.ToString();
}
else
    textBox3.Text = string.Empty;
nmaillet 97 Posting Whiz in Training

When you remove the item from the ListBox:

ListBox.Items.Remove(ListBox.SelectedItem);

The ListBox.SelectedIndex gets changed to -1, since an item is no longer selected. You could store the SelectedIndex to a local variable before removing any items. You should be careful with this though, you are removing the element from the ListBox, but only changing the element in the array. All elements after the removed index will be off by one.

nmaillet 97 Posting Whiz in Training

public in Customer.cs should be lower-case. Not sure if this is your problem, but when you get an error in just about any IDE it gives you a filename, and a line number. Why wouldn't you post this as well?

nmaillet 97 Posting Whiz in Training

Please define original state? Are you attempting to decrypt previously encrypted data? If so please post the encryption code or at least a copy of the data.

XOR encryption encrypts and decrypts using the same algorithm, even when using a key.

nmaillet 97 Posting Whiz in Training

"1>fatal error C1308: c:\...\Libs\Interop.Encore.dll: linking assemblies is not supported
1>LINK : fatal error LNK1257: code generation failed"

Do you have CLR support enabled? Are you gearing your application towards .NET or native code?

nmaillet 97 Posting Whiz in Training
nmaillet 97 Posting Whiz in Training

An external variable has a specific type. Therefore the compiler will do type-checking when compiling. You can also assign a value to a global variable at run-time.

As WaltP said, Macros are very different. When a Macro is referenced, the compiler simply copies the value and pastes it in the code where you've used it (before compiling). It is equivalent to using a Find & Replace tool in a text editor. It does allow for some additional functionality however, such as #ifdef/#ifndef, #undef and functions. Although those are somewhat dependent on the compiler.

nmaillet 97 Posting Whiz in Training

Probably not your issue, but why are you using double for ss . You should never really be checking a double with the == operator (unless checking for 0 I suppose). Floating point numbers are prone to small rounding errors.

nmaillet 97 Posting Whiz in Training

You started out right with if(bottomA < topB) . The proceeding three if statements would not give you the desired result though. You need to compare left to right, and top to bottom. For instance:

if(bottomA < topB)
    return false;
if(bottomB < topA)
    return false;
if(rightA < leftB)
    return false;
if(rightB < leftA)
    return false;
nmaillet 97 Posting Whiz in Training

That statement will not return true for 5, for two reasons. digit would not be greater than 5, it would be equal, and 5 mod 5 equals 0. Both would be false.

I don't really understand why you are performing the checks:

if((digit%2) !=0 && (digit%3) !=0){
if((digit > 5) && (digit%5) !=0){

You should first be checking if number is divisible by digit (ie. number % digit == 0 ). Then you should add in a for loop to determine if the digit is prime; probably as another function for simplicity's sake.

Since Project Euler is generally about efficiency, I should mention that:
a) you don't need to check if(digit > biggestPrime) since i is always increasing, each time it will be greater than the last.
b) since even numbers (except 2 of course) are never prime, you do not have to check them, and there will never be a factor greater than the number divided by 2 (unless the number itself is prime). You could reduce your for-loop to:

long long int halfNumber = number / 2;
for(long long int digit = 3; digit <= halfNumber; digit += 2)

P.S. Please preview your post before submitting, or edit it right afterwards. It is much easier to read code if the CODE tags are used properly.

nmaillet 97 Posting Whiz in Training

Both the 5 and 9 literals are integer, therefore the result will be an integer (not rounded; the decimal value is simply removed). You can explicitly declare them as double values by entering then as 5.0 and 9.0 respectively.

You may want to have a look at "Section 7.3 Operators" of the C# Language Specification.

nmaillet 97 Posting Whiz in Training

Just to clarify:

while (A)
{
    some_method();
}
other_method();

is executed like:

If A is false go to line 4.
    some_method();
    Go to line 1.
other_method();
Jazerix commented: Thanks :) +3
nmaillet 97 Posting Whiz in Training

while loops only loop as long as the expression evaluates to true. So once it checks the value, and its false it continues on. This would work if you wanted it to continuously show "TEST".

while(true)
    if(timerdone)
        MessageBox.Show("TEST");

Or if you only wanted it to show once:

while(!timerdone) ;
MessageBox.Show("TEST");
nmaillet 97 Posting Whiz in Training

You could use the SendInputs() function in the WinAPI. This function does not target particular windows however. First thing you'll need is structure definitions:

struct INPUT
    {
        public uint type;
        public MOUSEINPUT mi;
    }

    struct MOUSEINPUT
    {
        public int dx;
        public int dy;
        public uint mouseData;
        public uint dwFlags;
        public uint time;
        public IntPtr dwExtraInfo;
    }

In whatever class you'd be using it, declare the external function:

[DllImport("user32.dll")]
private static extern uint SendInput(uint nInputs, INPUT[] pInputs, int cbSize);

I did a quick test to move the cursor relative to its current position:

SendInput(0, null, Marshal.SizeOf(typeof(INPUT)));

            INPUT input = new INPUT();
            input.type = 0x0000;

            MOUSEINPUT mouseInput = new MOUSEINPUT();
            mouseInput.dx = 300;
            mouseInput.dy = 150;
            mouseInput.mouseData = 0;
            mouseInput.dwFlags = 0x0001;
            mouseInput.time = 0;
            mouseInput.dwExtraInfo = IntPtr.Zero;

            input.mi = mouseInput;

            INPUT[] inputArray = new INPUT[] { input };

            SendInput((uint)inputArray.Length, inputArray, Marshal.SizeOf(typeof(INPUT)));

Take a look at these references to modify it:
SendInput() Function
INPUT Structure
MOUSEINPUT Structure

nmaillet 97 Posting Whiz in Training

The only reason you are able to use the default .NET controls, is since http://schemas.microsoft.com/winfx/2006/xaml/presentation is declared as the default namespace. Otherwise you have to explicitly state a namespace alias; for instance, x:Key. Since VisualStateManager is not included in .NET 3.5, you'll have to add a reference to it.

I don't know how the exact namespace or assembly name of the WPF Toolkit off the top of my head, but you add an attribute to the ResourceDictionary similar to this:

xmlns:data="clr-namespace:System.Data;assembly=System"

Then reference it like:

<data:DataSet>
...
</data:DataSet>
nmaillet 97 Posting Whiz in Training

What farooqaaa said is correct of course. But, if you want to call the Click event of a control, without knowing which method is handling the event (e.g. event handler was changed), you have to inherit the control and expose the OnClick() method. For example:

public class MyButton : Button
{
    public void ClickMe()
    {
        OnClick(null);
    }
}

Events can only be invoked by the declaring class, even inherited classes cannot.