|
here is an article found on the internet:
http://www.herdsoft.com/ti/davincie/leon5i44.htm
which has following code:
//----------------------------------
TDib * theDib = new TDib( "MEINE.BMP");
HGLOBAL hg = HANDLE( *theDib );
LPBITMAPINFOHEADER pbm=(LPBITMAPINFOHEADER)GlobalLock(hg);
//----------------------------------
is it necessary or useful to lock a "new" pointer as code above?
|
|
|
|
|
It's actually locking a handle returned from the TDib * ( presumably an operator is defined to do this ).
|
|
|
|
|
do no type sentence which says nothing.
|
|
|
|
|
includeh10 wrote: do no type sentence which says nothing.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
erm...whats the process for creating a regular dll in visual 2005 express edition?
seems to be something which should be a doddle....
Bryce
-- modified at 20:32 Monday 13th November, 2006
|
|
|
|
|
Maybe the express edition is different, I am not using that one, but I have to do File->New->Project...->Win32->Win32 Project->Ok->Application Settings->Dll->Finish
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
correct there is a difference...the dll option is disabled.
i'm leaning to the thought that expess edition doesnt allow you to build something as basic as a dll
Bryce
|
|
|
|
|
Well that sucks;P
Here is something you can try, no guarantees it will work though:
Create a Win32 windows app, Then go to windows explorer, find the vcproj file for your project. Open it in a text editor, find the line that says "PreprocessorDefinitions=" and add the _USRDLL preprocess definition.
Then goto the source files and remove WinMain and add DllMain.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
Also, while you are in the vcproj file you should also adjust the linker options.
Look for the linker tool section, change the output name to a dll extension, and add the line:
ImportLibrary="$(TargetDir)$(TargetName).lib"
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
I created a very simple program in C++ that displays math problems the user must answer. I am trying to use a timer to diplay the time elapsed and fprintf() the time to a file for high scores (or low scores). I have included timer.h and I can display the time to the screen, but cannot write the time to a file. The timer displays the correct time, so I know it is working, but I cannot figure out how to assign the timer a variable or export it directly to the file. Any help would be appreciated.
Kenny
jmarkey@iastate.edu
|
|
|
|
|
If it's a console application and you're using SetTimer see this[^] article.
Steve
|
|
|
|
|
jmarkey wrote: I can display the time to the screen, but cannot write the time to a file.
If you are using fprintf(stdout, ...) to write to the screen, why not just replace stdout with a FILE pointer?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I am trying to read and write to the same file. Could this be a reason it is not writing? I open and close the file twice, once to read the scores "r" and once to write a score in "w". This is inefficient, but quick enough for my purposes. Is there any reason this will not work?
|
|
|
|
|
jmarkey wrote: I am trying to read and write to the same file. Could this be a reason it is not writing?
I doubt it.
jmarkey wrote: I open and close the file twice, once to read the scores "r" and once to write a score in "w".
Shouldn't be a problem. You could also open the file once in read+write mode, but that is unrelated to your problem.
That said, what exactly is the problem you are seeing?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I am trying to extract a value from a timer to compare it with other values (high scores). However, all timers I have tried return a double that cannot be manipulated, and displayed only by using the code-
cout << "\n\nYour time is " << t;
I don't know how exactly that code operates, so I would like to be able to use printf() to display the time. If you know of a timer that returns a value (to the hundredths place) that can be manipulated, please reply.
|
|
|
|
|
jmarkey wrote: However, all timers I have tried return a double...
This makes no sense. SetTimer() and the WM_TIMER message have no knowledge of double types. Perhaps you are thinking of something else.
jmarkey wrote: cout << "\n\nYour time is " << t;
Why are you not using endl ?
jmarkey wrote: I would like to be able to use printf() to display the time.
If you are writing C++, why?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
point 1: What is SetTimer() and WM_TIMER? I included the header file "timer.h" to time my program. I declare a timer t, start it with t.start(), stop it with t.stop(), and display the time as described before. While debugging the program, I inserted a breakpoint after t.stop() so I could check the value of it. I noticed the timer t had several sub-values. There are two long floats start_clock and start_time that I think have to do with the CPU clock ticks. There is also a double called acc_time that is what I am trying to extract from t. It is a decimal to the hundredths place and is exactly what I am trying to fprintf to the highscores file. This was the double I was referring to, sorry if I was not clear.
point 2: What is endl? I assume it is short for "endline" or something like that, but I have never seen and do not know how to use cout<
|
|
|
|
|
jmarkey wrote: What is SetTimer() and WM_TIMER?
SetTimer()
WM_TIMER
jmarkey wrote: What is endl?
endl
jmarkey wrote: Why does using printf() to display the time hinge on writing in C++?
Not exactly sure what you mean by this. While printf() can be used with both C and C++, most folks move on to streams (e.g., cout ) when they do C++ work.
jmarkey wrote: I would like to use printf() to write to the highscores file.
I already mentioned using fprintf() for this.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I think we are misunderstanding each other. Here is what I know:
1. I can write to the file using fprintf(), and have done so.
2. I can time my program and print the time to the screen using cout
Here is what I don't know:
1. What the heck is a stream? I have never heard of streams before.
2. I explained what values the timer contained in the last post. How can I
access the acc_time value? (acc_time is a double)
3. I am timing functions as they happen. I don't see how Set Timer() and
WM_TIMER will help, because as far as I can tell these timers count down to
zero. I need one that will count up until I stop it, and return a value
that can either be used in printf() or fprintf(), or converted to be used
in those functions.
So the only thing I am trying to do right now is figure out a way to get the time in a manageable form so I can manipulate it. Thank you for your help so far.
|
|
|
|
|
jmarkey wrote: What the heck is a stream?
It's what's used with cout .
jmarkey wrote: How can I
access the acc_time value? (acc_time is a double)
What's wrong with t.acc_time ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
hiiiiiiiiiiii..........
Q:
I have in my programe three files: SCANNER.CPP,tst_scanner.cpp and scaner.h
i need read and write from text file which is glopal. how i can do it?
the strange things if i put all programm in one file it is working as good.but whene i use three files it is have error(not define the glopal text file in some file).
i am using many wayes to solve this probleme(i define the glopal text file out of main or enter and enter of getT() or outer of it or the top of any file is .cpp or using 'extern' and....)but i did not get the solve.
pleeeeeeeeeeeeeeeeeeeeez i neeeeeeeeed to know how i do it? if i can opening the text file to be glopal in constructor of my class that good for mee.
NOTE: i need to use this hider of function: Tokens Scanner::getT()
I am writing in SCANNER.CPP this lines code:
#include<iostream>
#include"scanner.h"
#include<fstream>
static char ch;
using namespace std;
extern fstream myfile1;
int lineo=1;
Tokens Scanner::getT()
{
.
.
.
}
-------------and in main file tst_scanner.cpp i write this
#include<iostream>
#include"scanner.h"
#include<fstream>
using namespace std;
int line=1;
static char ch;
//extern fstream myfile1;
int main()
{
//extern fstream myfile1;
fstream myfile2, myfile1; //static fstream myfile1,myfile2;
Scanner S1;
Tokens T1;
myfile1.open( "C:\\fcode.txt", ios::in | ios::out );
myfile2.open( "C:\\fscan.txt", ios::in | ios::out|ios::app );
myfile1.get(ch);
myfile2<<"Tokens_Type"<<"\t\t\t"<<"Line Number"<<"\t\t"<<"Lexmes"<<endl;
do
="" {
="" t1="S1.getT();
" switch(t1.tokentype)
.
.
.
}while
=""
---------------------and="" in="" scaner.h="" i="" write="" this:
typedef="" enum="" {="" tok_ident,tok_il,kw_else,kw_if,kw_int,kw_return,kw_void,kw_while,tok_semicolon,
tok_plus,tok_star,tok_slash,tok_eq,tok_gt,tok_gt_eq,tok_lt,tok_lt_eq,tok_not_eq,tok_assign,tok_lbrace,
tok_rbrace,tok_lbracket,tok_rbracket,tok_lpar,tok_rpar,tok_comma,tok_minus,end,error}tokentypes;
class="" tokens
{
="" friend="" class="" scanner;
="" public:
="" tokentypes="" tokentype="" ;
=""
="" char*="" lexeme;
="" int="" newval;
};
class="" scanner
{
public:
="" scanner();="" constructor
="" tokens="" gett();="" -----------="" return="" object="" of="" (tokens).
="" -----------and="" tokentype,lexeme="" and="" line
};
=""
i="" have="" some="" time="" this="" error="" or="" no="" but="" the="" file="" not="" read="" scanner.cpp
--------------------configuration:="" test_scanner="" -="" win32="" debug--------------------
linking...
scanner.obj="" :="" lnk2001:="" unresolved="" external="" symbol="" "class="" std::basic_fstream<char,struct="" std::char_traits<char=""> > myfile1" (?myfile1@@3V?$basic_fstream@DU?$char_traits@D@std@@@std@@A)
Debug/test_scanner.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
test_scanner.exe - 2 error(s), 0 warning(s)
--------------------------------------------------
thanks for help!!!
|
|
|
|
|
extern means you define it somewhere else. I don't see where you are doing that.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
// extern in my code means how many i try to make text file glopal.
i try to put extern in difrent place and file but it is not work
in scsnner.cpp file in getT() function the text file that what i open it in main() not define.
can you tell me how and where put extern? and can you tell what the reason of this ERROR:
--------------------Configuration: test_scanner - Win32 Debug--------------------<br />
Linking...<br />
Scanner.obj : error LNK2001: unresolved external symbol "class std::basic_fstream > myfile1" (?myfile1@@3V?$basic_fstream@DU?$char_traits@D@std@@@std@@A)<br />
Debug/test_scanner.exe : fatal error LNK1120: 1 unresolved externals<br />
Error executing link.exe.<br />
<br />
test_scanner.exe - 2 error(s), 0 warning(s)
thanks.....
|
|
|
|
|
You get an unresolved external because you've not declared it anywhere, you've just put extern in various places, which tells the compiler that it's declared somewhere ( but not here ), but it never is.
Either way, what you want to do is nasty. You should wrap your file access in a static class, not make it a global like this.
|
|
|
|
|
immmmmmm ok..
can you plz explain that by using my code above?
|
|
|
|