|
Did you use glViewport?
Don't try it, just do it!
|
|
|
|
|
yeah, in my OnSize() function, I have a call to glViewPort to set the view's dimensions, however, whenever I alter the dimensions, it only affects the shapes themselves, but still paints the whole view black.
IloveCheeese
|
|
|
|
|
Hi, I have a simple code but I couldn't make it run...
#include "stdafx.h"<br />
<br />
typedef int DataType;<br />
<br />
const int MAX_SIZE = 50;<br />
<br />
void merge(DataType theArray[], int first, int mid, int last);<br />
void mergesort(DataType theArray[], int first, int last)<br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
int arrayToSend[4] = { 1, 2, 4, 3 };<br />
mergesort( arrayToSend, 0, 3 );<br />
return 0;<br />
}<br />
<br />
void merge(DataType theArray[], int first, int mid, int last)<br />
{<br />
DataType tempArray[MAX_SIZE];
<br />
int first1 = first;
int last1 = mid;
int first2 = mid + 1;
int last2 = last;
<br />
int index = first1;
for (; (first1 <= last1) && (first2 <= last2); ++index)<br />
{
if (theArray[first1] < theArray[first2])<br />
{ tempArray[index] = theArray[first1];<br />
++first1;<br />
}<br />
else<br />
{ tempArray[index] = theArray[first2];<br />
++first2;<br />
}
}
<br />
<br />
for (; first1 <= last1; ++first1, ++index)<br />
tempArray[index] = theArray[first1];<br />
<br />
for (; first2 <= last2; ++first2, ++index)<br />
tempArray[index] = theArray[first2];<br />
<br />
for (index = first; index <= last; ++index)<br />
theArray[index] = tempArray[index];<br />
}
<br />
void mergesort(DataType theArray[], int first, int last)<br />
{<br />
if (first < last)<br />
{
int mid = (first + last)/2;
mergesort(theArray, first, mid);<br />
mergesort(theArray, mid+1, last);<br />
<br />
merge(theArray, first, mid, last);<br />
}
}
I get errors like
d:\CD\myProjects\Homeworks\hw2Q4\hw2Q4.cpp(5): warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored
d:\CD\myProjects\Homeworks\hw2Q4\hw2Q4.cpp(5): error C2146: syntax error : missing ';' before identifier 'main'
d:\CD\myProjects\Homeworks\hw2Q4\hw2Q4.cpp(13): fatal error C1075: end of file found before the left brace '{' at 'd:\CD\myProjects\Homeworks\hw2Q4\hw2Q4.cpp(11)' was matched
Any help would be appriciated.
|
|
|
|
|
kromozom wrote:
d:\CD\myProjects\Homeworks\hw2Q4\hw2Q4.cpp(5): error C2146: syntax error : missing ';' before identifier 'main'
Find your main() function declaration (or in your case _tmain(...))
Look at the line just above it.
What is missing (clue is in the error message you recieved)?
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Ohh my goodness, I should take a sleep. Thank you friend. I have modified the code as;
#include <iostream><br />
<br />
using namespace std;<br />
typedef int DataType;<br />
<br />
int indexOfLargest(const DataType theArray[], int size);<br />
void selectionSort(DataType theArray[], int n);<br />
void swap(DataType& x, DataType& y);<br />
<br />
int main()<br />
{<br />
return 0;<br />
}<br />
<br />
void selectionSort(DataType theArray[], int n)<br />
{<br />
for (int last = n-1; last >= 1; --last)<br />
{ <br />
int largest = indexOfLargest(theArray, last+1);<br />
<br />
swap(theArray[largest], theArray[n - last]);<br />
<br />
}
}
<br />
int indexOfLargest(const DataType theArray[], int size)<br />
{<br />
int indexSoFar = 0;
for (int currentIndex = 1; currentIndex < size; <br />
++currentIndex)<br />
{
if (theArray[currentIndex] > theArray[indexSoFar])<br />
indexSoFar = currentIndex;<br />
}
<br />
return indexSoFar;
}
<br />
void swap(DataType& x, DataType& y)<br />
{<br />
DataType temp = x;<br />
x = y;<br />
y = temp;<br />
}
But this time I get the error of
d:\CD\myProjects\Homeworks\hw2Q4\hw2Q4.cpp(11): fatal error C1075: end of file found before the left brace '{' at 'd:\CD\myProjects\Homeworks\hw2Q4\hw2Q4.cpp(10)' was matched
How can I solve this one? Thanks...
|
|
|
|
|
Now your first line (#include statement) is incomplete.
Barry Etter
|
|
|
|
|
no no, it writes
#include < iostream >
there, but editor took it as a tag.
I really couldn't why this error is coming from.
|
|
|
|
|
You need to remove blocks of code until the error goes away, then start adding them back until you identify the problem.
Barry Etter
|
|
|
|
|
kromozom wrote:
d:\CD\myProjects\Homeworks\hw2Q4\hw2Q4.cpp(11): fatal error C1075: end of file found before the left brace '{' at 'd:\CD\myProjects\Homeworks\hw2Q4\hw2Q4.cpp(10)' was matched
The compiler is telling you that it could not find a closing brace '}' to match the opening brace on line 10 of your hw2Q4.cpp file.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
But I have friend, the all code is this. Can you take a look at it in your compiler? There is no unmatched curly bracket as far as I see. If someone can point for me I will be glad to see it?!
|
|
|
|
|
just insert this one as the very first line of your code:
#include "stdafx.h"
|
|
|
|
|
Thank you very much it worked. But this tme I got the errors like
hw2 error LNK2019: unresolved external symbol "void __cdecl selectionSort(int * const,int)" (?selectionSort@@YAXQAHH@Z) referenced in function _main
hw2 fatal error LNK1120: 1 unresolved externals
|
|
|
|
|
I've just received and application that has a COM Autmation interface (not sure if I'm describing that right). I need to write an application that will interface with it. Can anyone suggest a tutorial that will cover a way to do this?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
|
Yeah I looked thru here, but I'm not sure if they are talking about making an automation server or interfacing with one. On top of that there are none for how to do it with the .NET studio.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
i need to create security events such as failed login and success login events, and looking for a tool that will automate login attempts (will need to run repeatedly). i've been searching for one and can't find it. or maybe API? thx
|
|
|
|
|
You could write a small console app using the LogonUser and LogonUserEx function calls. Put calls into some loops using whatever user information you want - valid or not, for your testing.
|
|
|
|
|
Hello,
sometimes I got a network cable disconnect or network cable unplugged event, and I would like to develop a small app to check when it happens and to log it, what api should I use??
Thanks in advance
Paolo
|
|
|
|
|
Check out the ISensNetwork interface.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
It is the code from MSDN
It complies and links but does not executes giving the following error
File:i386\chkesp.c
line:48
The value of ESP was not properly saved across a fuction call.This is usually a result of calling function decleared with one calling convention with a funciton pointer decleared with a different calling convention.
#include <windows.h>
#include <setupapi.h>
#include <stdio.h>
DWORD Err;
HDEVINFO DoDeviceEnum( GUID InterfaceClassGuid)
/*
Routine Description:
Retrieves the device information set that contains that contains
the devices of the specified class.
Parameters:
InterfaceClassGuid - The interface class GUID.
Return Value:
If the function succeeds, the return value is a handle to the
device information set.
If the function fails, the return value is zero.
*/
{
HDEVINFO DeviceInfoSet;
HDEVINFO NewDeviceInfoSet;
// Create a device information set that will be the container for
// the device interfaces.
DeviceInfoSet = SetupDiCreateDeviceInfoList(NULL, NULL);
if(DeviceInfoSet == INVALID_HANDLE_VALUE) {
Err = GetLastError();
printf( "SetupDiCreateDeviceInfoList failed: %lx.\n", Err );
return 0;
}
// Retrieve the device information set for the interface class.
NewDeviceInfoSet = SetupDiGetClassDevsEx(
&InterfaceClassGuid, // address of guid required
NULL, // no enumerator
NULL, // no parent window handle (might not be a good idea…)
DIGCF_PRESENT | DIGCF_DEVICEINTERFACE, // flags
//DeviceInfoSet, // do not pass this in, not in function prototype
NULL, // NULL implies local machine
NULL // Reserved’ must be null
);
if(NewDeviceInfoSet == INVALID_HANDLE_VALUE)
{
Err = GetLastError();
printf( "SetupDiGetClassDevsEx failed: %lx.\n", Err );
return 0;
}
return NewDeviceInfoSet;
}
int main(int argc, TCHAR* argv[])
{
GUID var;
DoDeviceEnum(var);
return 0;
}
|
|
|
|
|
Put a breakpoint on the SetupDiCreateDeviceInfoList() statement and single-step through the code until you get to the statement that causes the error.
I cleaned up your code a bit to look like:
HDEVINFO DoDeviceEnum( void )
{
GUID InterfaceClassGuid;
HDEVINFO DeviceInfoSet,
NewDeviceInfoSet;
DeviceInfoSet = SetupDiCreateDeviceInfoList(&InterfaceClassGuid, NULL);
if (DeviceInfoSet != INVALID_HANDLE_VALUE)
{
NewDeviceInfoSet = SetupDiGetClassDevsEx(&InterfaceClassGuid,
NULL,
NULL,
DIGCF_PRESENT | DIGCF_DEVICEINTERFACE,
DeviceInfoSet,
NULL,
NULL);
if (NewDeviceInfoSet != INVALID_HANDLE_VALUE)
;
else
printf("SetupDiGetClassDevsEx failed: %lu.\n", GetLastError());
SetupDiDestroyDeviceInfoList(DeviceInfoSet);
}
else
printf("SetupDiCreateDeviceInfoList failed: %lu.\n", GetLastError());
return NewDeviceInfoSet;
}
void main( void )
{
DoDeviceEnum();
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I had created a structure with six members of type CString.
I am trying to send this structure using the 'Send' command.
A Pointer object is created for the structure.
At the receiving end i had created the same structure. But when i was trying to display the data , I got only a blank message box.
Can anyone solve this problem?
source prg
..........
Struct message
{
CString name;
...
};
message *obj=new message();
Send(obj,sizeof(struct message));
dest prog
........
Struct message
{
CString name;
...
};
message *obj=new message();
Receive(obj,sizeof(struct message));
MessageBox(obj->name); //blank message box was displayed ?
vinsankar
|
|
|
|
|
The problem with your code is that sizeof(struct message) is going to return the same number no matter what the size of the string. That is because the CString class has a pointer to a buffer which contains the actual string. You have just stumbled upon a problem that occurs very often. There are many ways around this, but the simpliest one I can think of would be to change your struct to:
<br />
struct message<br />
{<br />
char name[256];<br />
};<br />
sizeof(struct message) would then return 256. This method is inefficient, as the whole buffer would be transferred, and it would be tougher to work with the char arrays instead of the CString's.
Greba,
My lack of content on my home page should be entertaining.
|
|
|
|
|
why can't we use CString instead of character arrays ?
I am in need of CString values at the receving end.Because I
have to perform some trimming operations at the receiving side.
What is the real problem while displaying the values stored in structure?
Is there any other way to send a structure through the 'Send' command?
vinsankar
|
|
|
|
|
Hi,
I'm having trouble with using a particular COM object in an MFC application. Here's what happens. I create a brand new MFC application put some code in the message handler to initialize COM, create object, set some properties on the object etc. That works fine. However when I try the exact same code inside another, bigger application the code doesn't work.
First CoInitialize() returns RPC_E_CHANGED_MODE. I have no idea why because this is the first time I call it in the code. I use many other libraries it may be possible that some other library has initialize it. I can either ignore this returned value or put CoInitialize and other code into a thread, in either case problem 2 occurs.
Second, the program doesn't behave as it should. I try to debug it by stepping through the code. CoCreateInstance() works fine, then I set some options on this created instance, that works fine. Then I call another function and MSVC++ displays "First-chance exception...(NTDLL.DLL): Invalid Handle" and I can't debug any further.
How can I debug this? This particular code is identical between the two applications. Both applications seem to have the same project settings. I'm just out of ideas.
|
|
|
|