|
|
DavidCrow gave awesome answer In addition you can do following things
1. try to code out projects in other languages in c++ this will give u syntactical perfection
2. figure out things around you which can be renewed using c++
3.create your own problem statement and try to solve them
4.make an excel sheet about what you have done on dayly basis
5.u can do any thing if u decide
6.give yourself exposure in market by talking about c++ in Fouroms
best of luck find your way to success
|
|
|
|
|
Usually it is quite the opposite: C++ masters you.
|
|
|
|
|
Make your hands dirty by entering into solving some problems
|
|
|
|
|
Function containing for are not expected inline
|
|
|
|
|
|
Hi
The Win32 OWNERDRAWITEM is handled by WS_DRAWITEM in the form of wParam lParam message
While framework virtual function CStatic::DrawItem takes a LPDRAWITEMSTRUCT for a parameter
Am I missing something ?
|
|
|
|
|
That seems right, that kind of thing is common in MFC. In this case the lParam would need to be cast to a LPDRAWITEMSTRUCT. In MFC you don't need the cast, it's actually pretty similar.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Doi need a message map entry to get my CStatic::DrawItem to be called I have SS_OWNERDRAW but it is not being called
|
|
|
|
|
Are WS_VISIBLE and WS_CHILD styles set?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Just came back home yes both are set do I need to subclass the Static control
|
|
|
|
|
Yes, I believe so.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Have to Use Create DDX_Control wont do it
As aside what is the best tool to draw a nice bitmap of Text
|
|
|
|
|
How did you set SS_OWNERDRAW if you did it by PreSubclassWindow in MFC there is a big gotcha with Static Text.
ModifyStyle(0, SS_OWNERDRAW);
ModifyStyle(SS_TYPEMASK, SS_OWNERDRAW);
If you look at the bit field assignments you will see why you have to mask because unlike buttons with SS_OWNERDRAW there is overlap in bits between SS_RIGHT of static text and SS_OWNERDRAW.
In vino veritas
|
|
|
|
|
I set it in my resource file just SS_OWNERDRAW WS_CHILD WS_VISIBLE I tried many methods including SETBITMAP to display the bitmap nothing worked until I used Create and Drawitem
|
|
|
|
|
I use the bellow code to read binary file but it throws an exceptions at run time and sometimes gives a wrong results , please tell me what's the wrong ?
#include <stdio.h>
#include <stdlib.h>
unsigned long size,n;
int main()
{
unsigned char *buf;
FILE* fp;
fp=fopen ("myfile.bin","rb");
if (fp == NULL) {
fprintf(stderr, "Can't open the file");
exit(1);}
fseek (fp,0,SEEK_END);
size=ftell (fp);
fseek (fp,0,SEEK_SET);
if ((buf=(unsigned char*) malloc (size+1))==0)
printf("\n%s","allocation Error");
n=fread (buf,sizeof (buf),size,fp);
printf ("\n%02x %lu bytes read",buf[15],n);
free (buf);
fclose (fp);
return 0;
}
modified 11-Aug-16 16:40pm.
|
|
|
|
|
Fossi Bluman wrote: ...it throws an exceptions at run time... What exception? Where?
n=fread (buf,sizeof (buf),size,fp);
printf ("\n%02x %lu bytes read",buf[15],size);
I can tell you right now that these two lines will raise eyebrows. Among other things, size is the number of bytes to read, whereas n is the number of bytes actually read.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
modified 11-Aug-16 10:16am.
|
|
|
|
|
DavidCrow wrote: Among other things, size is the number of bytes to read, whereas n is the number of bytes actually read.
Just to clarify - the signature of fread() is
size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
where size is the size of each data element and nmemb is the number of elements read. The returned value is the number of data elements actually read. Thus
FILE *f;
struct mystruct foo[10];
size_t n;
n = fread(foo, sizeof(struct mystruct), 10, f);
after the call to fread(), n will contain the number of (struct mystruct) items read, not the number of bytes read. So if sizeof(struct mystruct) = 42 and the stream f contains 4 items between the current file pointer and the end of file, then fread() will return 4 (the number of items), not 168 (the number of bytes [42*4]).
|
|
|
|
|
All true, but that doesn't change the issue that the OP is having. I was simply hinting at the fact that size and n may differ, and the parameter being sent to printf() was incorrect.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
in your fread() statement, you have:
sizeof(buf) - the size of the pointer, at least 2 (on 16-bit processors), but typically 4 (32-bit) or 8 (64-bit) bytes these days.
size - size of file in characters (each character is defined to be 1 unit in size)
You are reading at least twice (four times / eight times) the data that you expected, overflowing the buffer.
Perhaps you meant to write:
n = fread(buf, sizeof(*buf), size, fp);
As another poster mentioned, your printf() statement also looks funny.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
this funny "fread" doing the job , exactly as i need , any way ,, how to make it not funny ?
|
|
|
|
|
Examine the printf() statement closely. You will see the following formatting:
%02x for buf[15]
%lu for size
The %02x formatting is meant for printing an unsigned int, but you are printing an unsigned char. In order to be certain that this works on all systems, cast buf[15] to unsigned int.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
then how to print the hexadecimal values in a format of two digits ?
|
|
|
|
|
Hello.
Here is another solution.
#include <iostream>
#include <fstream>
using namespace std;
int main (){
streampos size;
char * memblock;
cout<<" \n\n";
ifstream file ("myfile.bin", ios::in|ios::binary|ios::ate);
if ( file.is_open() ){
size = file.tellg();
memblock = new char [size+1];
file.seekg (0, ios::beg);
file.read (memblock, size);
file.close();
cout << "the entire file content of "<< size <<" bytes is in memory \n\n\n";
delete[] memblock;
}
else cout << "Unable to open file\n\n";
cout<<"Press ANY key to close.\n\n";
cin.ignore(); cin.get();
return 0;
}
modified 21-Aug-16 0:39am.
|
|
|
|
|
thank you for reply , but I use C language .
|
|
|
|