Labdabeta 182 Posting Pro in Training Featured Poster

Is it possible to do any logic with gl lists, I am trying to make a wrapper class for them and I have this code in the compile function:

glNewList(model1,GL_COMPILE);
    glBegin(GL_TRIANGLES);
    int pos=0;
    for (int i=0; i<numcmds; i++)
    {
        if (cmdtype[i]=='v')
        {
            glVertex(cmdarg[pos++],cmdarg[pos++],cmdarg[pos++]);
        }
        else if (cmdtype[i]=='t')
        {
            glTexture(cmdarg[pos++],cmdarg[pos++]);
        }
    }
    glEnd();
    glEndList();

where cmdtype is an array containing either 'v' or 't' specifying whether a vertex of a texture or a shape is being drawn. (I will add more functionality later (EG: Normals, Quads, Colours). The problem is that when I use CallLists on model1 I get a nothing drawn. Does this mean that I cannot have any logic at all between glNewList and glEndList?

Labdabeta 182 Posting Pro in Training Featured Poster

I have continued through NeHe's tutorials and it seems that I should be able to use colour and textures. Please tell me why loading textures is messing with my colours and if possible how to fix it?

Labdabeta 182 Posting Pro in Training Featured Poster

This is a conversion question that has me stumped. I need to convert an unsigned char to a signed float. Some examples:
0xFF becomes 1.0f
0x00 becomes -1.0f
0x80 becomes ~0.0f
The only idea that I could come up with was a massive switch statement. But a switch statement will be slow and I need this to run fast. Any ideas?

Labdabeta 182 Posting Pro in Training Featured Poster

I looked at that, it didn't help. I really need this to work. It seems that I can get either the texture to load or the colours to draw correctly but not both. Does this mean that I cannot combine drawing with colours and drawing with textures?

Labdabeta 182 Posting Pro in Training Featured Poster

Sorry for the double post. I would just like to add that I have indeed tried this:

(echo helo; echo "mail from:(my email address)"; echo "rcpt to:(my email address)"; echo DATA; echo SUBJECT:(my subject); echo "(my message)";echo .)|telnet (My email smtp) 25

And it failed :(

Labdabeta 182 Posting Pro in Training Featured Poster

I will have to check that. Where can I find the documentation for BITMAP. I have never used them before and have no clue what fields they have.

Labdabeta 182 Posting Pro in Training Featured Poster

I have the following working fine from the command line:

telnet (my email smtp) 25
helo
mail from:(my email address)
rcpt to:(my email address)
DATA
SUBJECT:(my subject)
(my message)
.

This is sending me an email. My problem is that I need to emulate all of this from either a c++ file or a batch file. How can I pass instructions to telnet from a batch file?

Labdabeta 182 Posting Pro in Training Featured Poster

*FACEPALM*
Drat! Foisted by my own spam filter. -Sheldon Cooper
As it turns out all the random methods I tried worked. They just ended up in my spam filter. Thank you for the help anyways!

Labdabeta 182 Posting Pro in Training Featured Poster

I am having some major issues with OpenGL textures. I have the following code to load a glTexture (typedef ed as a GLuint):

glTexture LoadBMP(const char *fname)
{
	HBITMAP hBMP;
	BITMAP	BMP;
	glTexture texid;
	glGenTextures(1, &texid);
	hBMP=(HBITMAP)LoadImage(GetModuleHandle(NULL), fname, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE );
	if (!hBMP)
		return NULL;
	GetObject(hBMP, sizeof(BMP), &BMP);
	glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
	glBindTexture(GL_TEXTURE_2D, texid);								// Bind To The Texture ID
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);	// Linear Min Filter
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);	// Linear Mag Filter
	glTexImage2D(GL_TEXTURE_2D, 0, 3, BMP.bmWidth, BMP.bmHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP.bmBits);
	DeleteObject(hBMP);													// Delete The Object
	return texid;														// Loading Was Successful
}

It works but for some reason it causes all of my drawings to get dark.
Here are 2 links to my program running, both with and without a texture:
Without a texture: http://i1221.photobucket.com/albums/dd464/lambdabeta/goodgl.jpg
With a texture: http://i1221.photobucket.com/albums/dd464/lambdabeta/badgl.jpg

Does anybody know what is causing the colour mix up?

Labdabeta 182 Posting Pro in Training Featured Poster

I have a problem. I have tried absolutely everything from libcurl to telnet commands. For some unknown reason they all end up giving me some kind of warning or another saying that the message simply could not be sent. I was thinking maybe since I use an unusual Email provider I am unable to send emails or something. But I have the smtp so it shouldn't be too big a problem. Any ideas of why I cannot send my emails?

Labdabeta 182 Posting Pro in Training Featured Poster

I have been googling around and have found that the TI calculator that I use uses a z80 chip. I was wondering if it is possible to use assembly rather than the default program language of the calculator to write programs for it. Any ideas of how I could find documentation for this?

Labdabeta 182 Posting Pro in Training Featured Poster

That was an awesome link! You are right, google is our friend. Thanks a lot!

Labdabeta 182 Posting Pro in Training Featured Poster

I don't fully understand. Is there some way to find some kind of tutorial for libcURL?

Labdabeta 182 Posting Pro in Training Featured Poster

How can I send an email through C++. I need to make the following:

bool SendMail(char* from, char* to, char* title, char* msg)
{
    //What now?
    //Return true on success, false otherwise
}
Labdabeta 182 Posting Pro in Training Featured Poster

Is there any software out there that can help me create 3d models for use with OpenGL drawing of models (i.e: triangles, square and polygons in 3d space). I need to be able to make polygons in 3d and be able to access the values of the vertexes. Does anybody know any software that meets this description?

Labdabeta 182 Posting Pro in Training Featured Poster

*FACEPALM*
I forgot these lines in my header:

if (!wglMakeCurrent(hDC,hRC))
    {
        Kill();
        ERR("Fatal Error!","Failed to create a rendering context.");
        return false;
    }

Since I never make the current, I can't unmake current in Kill() and the screen is messed up. Thanks anyways!
*STILL FACEPALMING*

Labdabeta 182 Posting Pro in Training Featured Poster

I tried messing around with my pixelformatdescriptor with no luck. If it will help here is a link to a screen shot of my program... it is not impressive!

http://i1221.photobucket.com/albums/dd464/lambdabeta/failedTEST.jpg?t=1305577500

Labdabeta 182 Posting Pro in Training Featured Poster

I decided to post this problem in a new thread. I have a simple program in OpenGL and it doesn't work. What happens is that a transparent window forms and when you hit the 'X' it says that the Release of the Device Context and Rendering Context failed. Here is the code:

3dH.h:

#ifndef h3dH_H
#define h3dH_H
#include <windows.h>
#include <windowsx.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\GLAUX.h>
#define ERR(X,Y) MessageBox(NULL,Y,X,MB_OK|MB_ICONEXCLAMATION)
#define QUESTION(X,Y) MessageBox(NULL,Y,X,MB_YESNO|MB_ICONEXCLAMATION)
#define MESSAGE(X) PeekMessage(&X,NULL,0,0,PM_REMOVE)
#define Main() WINAPI WinMain(HINSTANCE hInstance,HINSTANCE prevInstance,LPSTR cmdline,int cmdshow)
typedef void(*DrawFunc)(bool *);
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
bool KEY[256];
int mouse_x;
int mouse_y;
int deltascroll;
bool active;
bool fullscreen;
HDC hDC;
HGLRC hRC;
HWND hWnd;
HINSTANCE hInstance;
char *classname;
void SetMousePos(int x, int y);
void Resize(int w, int h);
void Resize(int w, int h, double vangle);
void Resize(int w, int h, double vnear, double vfar);
void Resize(int w, int h, double vangle, double vnear, double vfar);
bool Init();
bool Draw();
bool Draw(DrawFunc draw);
void Step();
void Kill();
bool Create(char *title, int width, int height, int bpp, bool fscreen);
bool Create(char *title, int width, int height, int bpp, bool fscreen, int posx, int posy);
bool Create(char *title, int width, int height, int bpp, bool fscreen, char *cname);
bool Create(char *title, int width, int height, int bpp, bool fscreen, int posx, int posy, char *cname);

void SetMousePos(int x, int y)
{
    SetCursorPos(x,y);
    POINT mpos;
    GetCursorPos(&mpos);
    mouse_x=mpos.x;
    mouse_y=mpos.y;
}
void Resize(int width, int height, double vangle, double vnear, double vfar)
{
    if (height==0)
        height=1;
    glViewport(0,0,width,height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(vangle,(float)width/(float)height,vnear,vfar); …
Labdabeta 182 Posting Pro in Training Featured Poster

Not to rush the more experienced GUI programmers but... where are you guys?

Labdabeta 182 Posting Pro in Training Featured Poster

Ok, it was the weird windows typedefs that got me. Anyways I did it and it said that the command completed successfully? Nonetheless the window was clear (I could see my code right through it) and it still said release of DC and RC had failed. What now?

Labdabeta 182 Posting Pro in Training Featured Poster

I clickied and I don't understand it. I even copied and pasted the code. Still nothing!

Labdabeta 182 Posting Pro in Training Featured Poster

How do you parse the DWORD into a descriptive c style string?

Labdabeta 182 Posting Pro in Training Featured Poster

I really need this test program to work. All it does is show an empty window (transparent contents) and when you exit it says "Release of Device Context and Rendering Context failed." Here is the code:
3dH.h:

#ifndef h3dH_H
#define h3dH_H
#include <windows.h>
#include <windowsx.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\GLAUX.h>
#define ERR(X,Y) MessageBox(NULL,Y,X,MB_OK|MB_ICONEXCLAMATION)
#define QUESTION(X,Y) MessageBox(NULL,Y,X,MB_YESNO|MB_ICONEXCLAMATION)
#define MESSAGE(X) PeekMessage(&X,NULL,0,0,PM_REMOVE)
typedef void(*DrawFunc)(int *);
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
bool KEY[256];
int mouse_x;
int mouse_y;
int deltascroll;
bool active;
bool fullscreen;
HDC hDC;
HGLRC hRC;
HWND hWnd;
HINSTANCE hInstance;
char *classname;
void SetMousePos(int x, int y);
void Resize(int w, int h);
void Resize(int w, int h, double vangle);
void Resize(int w, int h, double vnear, double vfar);
void Resize(int w, int h, double vangle, double vnear, double vfar);
int Init();
int Draw();
int Draw(DrawFunc draw);
void Step();
void Kill();
int Create(char *title, int width, int height, int bpp, bool fscreen);
int Create(char *title, int width, int height, int bpp, bool fscreen, int posx, int posy);
int Create(char *title, int width, int height, int bpp, bool fscreen, char *cname);
int Create(char *title, int width, int height, int bpp, bool fscreen, int posx, int posy, char *cname);

void SetMousePos(int x, int y)
{
    SetCursorPos(x,y);
    POINT mpos;
    GetCursorPos(&mpos);
    mouse_x=mpos.x;
    mouse_y=mpos.y;
}
void Resize(int width, int height, double vangle, double vnear, double vfar)
{
    if (height==0)
        height=1;
    glViewport(0,0,width,height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(vangle,(float)width/(float)height,vnear,vfar);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
}
void Resize(int width, int height, double vnear, double vfar)
{
    Resize(width,height,45.0f,vnear,vfar);
}
void Resize(int width, int height, double vangle)
{
    Resize(width,height,vangle,0.1f,100.0f); …
Labdabeta 182 Posting Pro in Training Featured Poster

But Courier New does have identical 'l' and '1' characters... I use lucida sans... but it has TINY spaces.

Labdabeta 182 Posting Pro in Training Featured Poster

I did not know where to ask this question so I have put it here, feel free to move it if it is in the wrong place. My issue is that I cannot stand any of the usual programming fonts because letters tend to be the same, either '1' and 'l' or 'l' and 'I'. I want to know if there is a good, simple, not irritating, small font that could be used for programming that has a full set of unique characters? (or must I make my own?)

Labdabeta 182 Posting Pro in Training Featured Poster

Wow, I cna't spell. Anyways, I ran it and it still didn't really work. The sequence of events/messages was:
Fullscreen? NO
A transparent window appears.
Hit 'X'
Release of DC and RC failed
Could not unregister class

Why did I get the errors?

Labdabeta 182 Posting Pro in Training Featured Poster

To elaborate (since I am very anxious) I am using NeHe's tutorials and my results for tutorial 1 on windows was a list of errors:

D:\Programming\C++\OPENGLTEST\test1.cpp||In function `GLvoid ReSizeGLScene(GLsizei, GLsizei)':|
D:\Programming\C++\OPENGLTEST\test1.cpp|14|error: `glViewPort' was not declared in this scope|
D:\Programming\C++\OPENGLTEST\test1.cpp|14|warning: unused variable 'glViewPort'|
D:\Programming\C++\OPENGLTEST\test1.cpp||In function `int InitGL()':|
D:\Programming\C++\OPENGLTEST\test1.cpp|25|error: `glClearColour' was not declared in this scope|
D:\Programming\C++\OPENGLTEST\test1.cpp|25|warning: unused variable 'glClearColour'|
D:\Programming\C++\OPENGLTEST\test1.cpp||In function `BOOL CreateGLWindow(char*, int, int, int, bool)':|
D:\Programming\C++\OPENGLTEST\test1.cpp|104|error: `bits' was not declared in this scope|
D:\Programming\C++\OPENGLTEST\test1.cpp|108|error: `MD_YESNO' was not declared in this scope|
D:\Programming\C++\OPENGLTEST\test1.cpp|108|warning: unused variable 'MD_YESNO'|
D:\Programming\C++\OPENGLTEST\test1.cpp|104|warning: unused variable 'bits'|
D:\Programming\C++\OPENGLTEST\test1.cpp|126|error: `dxStype' was not declared in this scope|
D:\Programming\C++\OPENGLTEST\test1.cpp|126|warning: unused variable 'dxStype'|
D:\Programming\C++\OPENGLTEST\test1.cpp|129|error: invalid conversion from `long int' to `HWND__*'|
..\..\CodeBlocks\MinGW\include\winuser.h|3472|error: too many arguments to function `HWND__* CreateWindowExA(DWORD, const CHAR*, const CHAR*, DWORD, int, int, int, int, HWND__*, HMENU__*, HINSTANCE__*, void*)'|
D:\Programming\C++\OPENGLTEST\test1.cpp|129|error: at this point in file|
D:\Programming\C++\OPENGLTEST\test1.cpp|143|error: `bits' was not declared in this scope|
D:\Programming\C++\OPENGLTEST\test1.cpp|143|warning: unused variable 'bits'|
D:\Programming\C++\OPENGLTEST\test1.cpp||In function `LRESULT WndProc(HWND__*, UINT, WPARAM, LPARAM)':|
D:\Programming\C++\OPENGLTEST\test1.cpp|223|error: `umsh' was not declared in this scope|
D:\Programming\C++\OPENGLTEST\test1.cpp|223|warning: unused variable 'umsh'|
||=== Build finished: 10 errors, 7 warnings ===|

My source code is:

#include <windows.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\GLAUX.h>
HGLRC hRC=NULL;
HDC hDC=NULL;
HWND hwnd=NULL;
HINSTANCE hInstance;
bool keys[256];
bool active=TRUE;
bool fullscreen=TRUE;
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
GLvoid ReSizeGLScene(GLsizei width,GLsizei height)
{
    if (height==0)
        height=1;
    glViewPort(0,0,width,height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    //Viewing angle,aspect ratio,closest drawable,farthest drawable
    gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
};
int InitGL(GLvoid)
{
    glShadeModel(GL_SMOOTH);
    glClearColour(0.0f,0.0f,0.0f,0.0f);
    glClearDepth(1.0f);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
    return TRUE;
}
int DrawGLScene(GLvoid)
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    return TRUE;
};
GLvoid KillGLWindow(GLvoid)
{ …
Labdabeta 182 Posting Pro in Training Featured Poster

Can somebody help me, I wish to learn OpenGL and I don't understand how to set it up. I am using a windows XP machine with Code::Blocks 8.2 and MingGW. How do I get OpenGL working?

Labdabeta 182 Posting Pro in Training Featured Poster

Thanks, those ideas helped a lot!

Labdabeta 182 Posting Pro in Training Featured Poster

Thanks, that works!

Labdabeta 182 Posting Pro in Training Featured Poster

I need a way to do the following and I cannot think of one, this is what I have so far:

typedef Obj2*(*Reaction)();
class Obj1
{
    public:
    Reaction reaction;
};
class Obj2
{
    public:
    unsigned int numobj1;
    Obj1 *objects;
};
class Obj3:Obj2
{};

Can you find any way of doing this within the syntactical rules of C++?

Labdabeta 182 Posting Pro in Training Featured Poster

I have the following trig functions, but I am wondering if there is a faster algorithm that I could implement:

static const double SINMIN=0.0009999998333333;
    static const double COSMIN=0.9999995000000417;
    static const double TANMIN=0.0010000003333334;
    static const double E=2.718281828459045235360;
    static const double PI=3.14159265358979323846;
    static const double MINVAL=0.01;
    double sin(double ax)
{
    double x=aabs(ax);
    if (x==MINVAL)
    {
        switch (quadrant(ax))
        {
            case 1:
            case 2:
            return SINMIN;
            case 3:
            case 4:
            return -SINMIN;
        }
    }
    else
        return (SINMIN*cos(x-MINVAL)+COSMIN*sin(x-MINVAL));
}
    double cos(double x)
{
    if (x==MINVAL)
    {
        switch (quadrant(ax))
        {
            case 1:
            case 4:
            return COSMIN;
            case 2:
            case 3:
            return -COSMIN;
        }
    }
    else
        return (COSMIN*cos(x-MINVAL)+SINMIN*sin(x-MINVAL));
}
    double tan(double x)
{
    if (x==MINVAL)
    {
        switch (quadrant(ax))
        {
            case 1:
            case 3:
            return TANMIN;
            case 2:
            case 4:
            return -TANMIN;
        }
    }
    else
        return ((TANMIN+tan(x-MINVAL))/(1.0000000000000-(TANMIN*tan(x-MINVAL))));
}
Labdabeta 182 Posting Pro in Training Featured Poster

Thank you very much!

Labdabeta 182 Posting Pro in Training Featured Poster

Thanks, VLC is awesome, quick (hopefully) follow-up question that may or may not be related. What is the standard for screen dimensions and pixel density, E.G.: My screen is 1440x900 px at 96 dpi.

Labdabeta 182 Posting Pro in Training Featured Poster

How can you play videos in C++, I am quite willing to use more than less any headers, I basically need a code that will work like this:

#include "PlayVideos.h"
int main(int argc, char *argv[])
{
    SDL_Surface *screen=SDL_SetVideoMode(WINWIDTH,WINHEIGHT,WINBPP,SDL_SWSURFACE);
    ShowVideo("MyVideo.avi",0,0,screen);//play a video at position 0,0 and apply it to the screen while playing sound
    return 0;
}

or if it can't be done via blitting to a screen surface then I would settle for an external command like:

#include "PlayVideos.h"
int main(int argc, char *argv[])
{
    ShowVideo("MyVideo.avi");//Play a video
    return 0;
}

Any Ideas?

Labdabeta 182 Posting Pro in Training Featured Poster

I am looking to make a 3D game, I have made plenty of fun ones in 2D using SDL but have yet to attempt a 3D (fps style) game. Does anybody know either a way to do 3D with SDL, or some other similar or easy to use library that would allow me to use 3D?

Labdabeta 182 Posting Pro in Training Featured Poster

Basically I need to convert a binary number in the form of a string into the same number in decimal format in the form of a string. The numbers have to be able to handle upwards of 100 bytes, so storing them to ints just will not do.

Labdabeta 182 Posting Pro in Training Featured Poster

I have a problem that I am having trouble solving. I have a string of undefined length containing '0' or '1'. I need to convert this string to decimal... but I CANNOT store it in anything but another string. My issue is how to do this?! I have been thinking of maybe using base 1024, convert it to base 1000 + base 24 and store the 24 in an unsigned long long int... but even that might not work. Any ideas?

Labdabeta 182 Posting Pro in Training Featured Poster

Thanks, I decided to go with integers from 0-74 and use dynamic arrays to pass multiple countries, thanks anyways.

Labdabeta 182 Posting Pro in Training Featured Poster

I am making a diplomacy tool, for the board game diplomacy. I need to make a map of each territory. I have a 75 #define MAP_"NAME" lines but I don't know how to set them to a mask value that can be checked since I don't know any 75-bit or larger datastructures that can be declared as datatype=0x<lots of digits>. How do I make a new datatype of X-bytes to store this that can be defined as such? Any help would be appreciated!!!

Labdabeta 182 Posting Pro in Training Featured Poster

Hello, I have a few questions about Assembly. I am extremely new to it!

Question 1:
How do you write functions in assembly? Is it even possible?

Question 2:
How do you get an input to a dd variable type (do I have to do the math on four db inputs?)

Question 3:
Is it possible to make arrays in Assembly? If so how?

Thank you for any help! I am using masm32 with 16-bit link and CodeView v4.

Labdabeta 182 Posting Pro in Training Featured Poster

If I have a templated storage class, how can I create a specialized template for nested storage class. I already know how to specialize pointer template, but I don't know how to specialize this. EG:

template <typename Type>
class Array
{
///Array class code
};
int main()
{
    Array<int> rob;
    Array<Array<int> > bob;//I need bob to be specialized, but not rob
    return 0;
}

Is this possible?

Labdabeta 182 Posting Pro in Training Featured Poster

This is not too hard as far as I can tell. Your post is a little vague, but I think that you should just store the random number in a variable and check it against all the elements of your array.

Labdabeta 182 Posting Pro in Training Featured Poster

The code is in a header file, it is a statistics header that deals with dynamic arrays, and allows for convolution of said arrays, and calculation of certain statistical properties, such as standard deviation of said arrays.

Labdabeta 182 Posting Pro in Training Featured Poster

Is there any way to implement a scope change for the template keyword? I have a templated class with almost 100 different functions and my code looks disgusting with my external declarations. Is there any way to implement a scope increase for template? EG:

template <typename Type>
class TypeClass
{
    public:
    Type a();
    Type b();
    Type c();
};
//Without template scope:
template <typename Type>
TypeClass<Type> A();
template <typename Type>
TypeClass<Type> B();
template <typename Type>
TypeClass<Type> C();
//With template scope:
template w/ scope <typename Type>
TypeClass<Type> A();
TypeClass<Type> B();
TypeClass<Type> C();

Is this at all possible, or should I just copy "template <typename Type>" into my clipboard and reuse it?

Labdabeta 182 Posting Pro in Training Featured Poster

Is it possible to overload an operator for a built-in type? And if so what is it's syntax?
EG:

//Use of overloaded operator^ for types double and double (assuming it is overloaded for exponent):
double a=10.0;
double b=2.5;
double pow=a^b;//pow is approximately 316.22....
Labdabeta 182 Posting Pro in Training Featured Poster

Thank you very much!

Labdabeta 182 Posting Pro in Training Featured Poster

I am having trouble with a program that I am writing. I cannot seem to be able to destroy a window. I know the DestroyWindow function but it only works on windows that my application owns. Is there any way to destroy a window that is not owned by my application using windows API? (I was thinking of maybe writing some kind of keysym function that would press ALT-TAB then check the window name, then press ALT-F4 if necessary)

Labdabeta 182 Posting Pro in Training Featured Poster

I am having a lot of trouble getting the following to work and I think it is because of file issues:

int GetMinutes()
{
    fstream file(FNAME);
    char num[101];
    if (!file.is_open())
        Error("FILE NOT OPEN!");
    file.getline(num,100);
    file.close();
    return atoi(num);
}
int main(int argc, char *argv[])
{
    LARGE_INTEGER timestart, timestop, tickspersecond;
    QueryPerformanceFrequency(&tickspersecond);
    QueryPerformanceCounter(&timestart);
    Sleep(5);
    HWND window=GetForegroundWindow();
    int minutes=GetMinutes();
    char *caption;
    sprintf(caption, "%i minute timer.", minutes);
    bool counting=true;
    do
    {
        QueryPerformanceCounter(&timestop);
        int secondsleft=(minutes*60)-((timestart.QuadPart-timestop.QuadPart)/tickspersecond.QuadPart);
        char *message;
        sprintf(message, "%02i:%02i.%02i", secondsleft/3600, (secondsleft-((secondsleft/3600)*3600))/60, secondsleft-(((secondsleft-((secondsleft/3600)*3600))/60)*60)-((secondsleft/3600)*3600));
        counting=(secondsleft>=0);
    }while (counting);

I left out some of the code that I wish to keep to myself. But I have isolated the problem and it seems as though while loop is never excecuting. This happened before I changed from while{} to do{}while as well. Any ideas why this isn't working?

Labdabeta 182 Posting Pro in Training Featured Poster

Thanks, I guess it isn't possible. I just thought that maybe there could be a way to encrypt the .h file such that it can still be read directly, but I guess not.