|
|
Besides the fact that it has nothing to do with the question asked?
Like I stated, it leaks. "Only" one GDI object - you get lucky - the system
cleans up most of the problems. Here's an analysis:
CDC m_dc,m_dc2;
m_dc.CreateCompatibleDC(GetDC());
m_dc2.CreateCompatibleDC(GetDC());
HBITMAP hbit=CreateCompatibleBitmap(GetDC()->m_hDC,800,600);
HBITMAP hbit2=CreateCompatibleBitmap(GetDC()->m_hDC,800,600);
hbit=(HBITMAP)m_dc.SelectObject(hbit);
<font color="Red">
hbit2=(HBITMAP)m_dc2.SelectObject(hbit2);
<font color="Red">
hbit=(HBITMAP)LoadImage(NULL, _T("e:\\8bit.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
<font color="Red">
hbit=(HBITMAP)m_dc.SelectObject(hbit);
<font color="Red">
m_dc.TextOut(0,0,_T("And is this your answer"),23);
m_dc2.BitBlt(300,300,200,200,&m_dc,0,0,SRCCOPY);
hbit2=(HBITMAP)m_dc2.SelectObject(hbit);
<font color="Red">
CImage m_Image;
m_Image.Attach(hbit2);
m_Image.Save(_T("e:\\8bit_test.bmp"));
m_Image.Destroy();
<font color="Red">
m_dc.DeleteDC();
m_dc2.DeleteDC();
DeleteObject(hbit);
<font color="Red">
DeleteObject(hbit2);
<font color="Red">
<font color="Red">
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hey Mark thanks for your help.
|
|
|
|
|
Hi..
Previously I was using Modal dialog box with Thread, to continue one process and showing the dialog box continuously. But as I am getting problem with thread I need to use Modeless dialog Box. But when I replace the code of Modal Dialog box with Modeless Dialog Box. It hangs when redrawn.
i.e. When it redrawns nothing displays in the dialog box.
The Code I am using is as follows
My application is such, that continuously check the data from the server and displys on the dialog.
hDisOwnDlg=CreateDialog( g_hInst, MAKEINTRESOURCE( IDD_DISOWN ), NULL, DisOwnDlgProc );
ShowWindow(hDisOwnDlg,SW_SHOW);
Please Help me.
-- modified at 10:11 Thursday 1st November, 2007
|
|
|
|
|
Did you use of any function or event like WM_SIZE on your project? does your previous problem solve?
|
|
|
|
|
No i am not using WM_SIZE. and my previos problem hasn't been solved.
|
|
|
|
|
What thread are you creating the dialog on?
What thread do you do the continuous checking on?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have function that retrives the data from Internet Server throught Socket after some interval and show it on the dialog box. Previously I was using Modal Dialog box, calling this function through thread before creating dialog and termination thread when Dialog Ends.
But I think if I will use the Modeless Dialog box the above thing will be much easy. And So replaced the code of modal dialog box with Modeless Dialog box. But as I told earlier it gets blank when it redrawns.
|
|
|
|
|
Mark Salsbery wrote: What thread are you creating the dialog on?
What thread do you do the continuous checking on?
Well if you're doing processing on the same thread the modeless dialog
was created on, then that can cause the dialog not to get its
WM_PAINT messages (and any others).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I have created a Local User Account programmatically say "MyUser" and then Iam Creating a process as MyUser. From within this process( which means Iam working as "MyUser") I have created a Pdf file and then Iam trying to open it Programmatically using DOS command "cmd /c start myfile.pdf". But the Pdf file is not getting opened. Even when I click on it. It Says "Access denied". The Same file if I login using "MyUser" it is being opened.Then after If Iam trying to Open it Programmatically or Normally I could open the File from my current user Account.
So,Is it a must for me to login as "MyUser" atleast once to work with that user Programmatically?
What I observed is once I login as that user, In Documents and Settings a folder is created under the name "MyUser".
So Is there any thing more I need to do apart from creating a user Programmatically?
Any suggestions would be helpful.
Thanks in Advance.
Today is a gift, that's why it is called the present.
|
|
|
|
|
Firstly, do you know the freshly created pdf exists?
If so, it probably was created so that only MyUser can open it.
Forgetting acrobat etc - can you copy the file using explorer? If not, then you may need to modify the CreateFile code that MyUser runs to use a security context (one of the params that's usually NULL) to create the file with "everyone can read this" privileges.
*Then* worry about whether the file is decent.
You may even want to start testing by creating a text file with "hello" in it, so you can use simpler software to check things out.
Iain.
|
|
|
|
|
narayanagvs wrote: Iam trying to open it Programmatically using DOS command "cmd /c start myfile.pdf".
Why not just use ShellExecute(hWnd, "open", "myfile.pdf", ...) ?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
My application works as below.
Client sends its MAC address and Wait time(in seconds) to server and goes to sleep state.
Server receives them and sleeps for received no. of seconds. After that time period, server sends Magic Packet to client to wake it up.
Now the problem is, if Client sends Wait Time less than 120 seconds, server wakes up the client successfully. But if that time period is 120 or greater than 120, client does not wake up even if server sends magic packet successfully. What could be probable cause for the same.
|
|
|
|
|
Hello,
I have a CDatabase object.But the following ExecuteQuery doesn't work.It gives an error "Syntax error in field definition"
CDatabase CurrentDatabase;
CurrentDatabase.ExecuteSQL("Create Table Purchase (Amt decimal(10,2))");
but
the following works
CurrentDatabase.ExecuteSQL("Create Table Purchase (Amt int)");
I have checked with SQL both the statements have right syntax.
What must be the problem?
Prithaa
|
|
|
|
|
prithaa wrote: CurrentDatabase.ExecuteSQL("Create Table Purchase (Amt decimal(10,2))");
Can you execute this statement from within SQL itself? Have you tried:
CurrentDatabase.ExecuteSQL("Create Table Purchase (Amt decimal(10))"); or
CurrentDatabase.ExecuteSQL("Create Table Purchase (Amt decimal)");
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello,
Thanks for your reply.
I tried te syntax with Access it did not work in Access.
I want to create a table with a float field.I checked the SQL Create command which says decimal(10,2) for decimal values.
But it doesn't seem to work .
What should I do for decimal vlues?
Prithaa
|
|
|
|
|
prithaa wrote: I checked the SQL Create command which says decimal(10,2) for decimal values.
It matters not what SQL says about the syntax, as you are creating the table within Access. Check its documents instead.
prithaa wrote: What should I do for decimal vlues?
Have you tried:
CurrentDatabase.ExecuteSQL("Create Table Purchase (Amt double)");
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi all,
I am facing strange problem. I am executing A.exe and i wrote code in that binary to update the resource of itself ( that is A.exe itself).. But i am not able to update the resource..Is it permitted ?? I think its not ...even its not giving ny error... whats the problem with it ??
Thnx
LiveShell
|
|
|
|
|
Are you using BeginUpdateResource UpdateResource and EndUpdateResource ?
If possible could you please share your code ?
Regards,
Paresh.
|
|
|
|
|
yeah m using all these apis.. n even call to api returns successful...so i am amazed..
following is the code snippet
HANDLE hResource = BeginUpdateResource(szCVCreatorFile.c_str(), FALSE);
if(hResource == NULL)
{
return false;
}
if (UpdateResource( hResource,
"LICINFO",
MAKEINTRESOURCE(IDR_LICINFO),
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
pcEncodedData,
uiOutLen) == FALSE)
{
return false;
}
if(EndUpdateResource(hResource, FALSE) == FALSE)
{
return false;
}
|
|
|
|
|
Hi guys.. wanna ask abt a question on c programming.. no c++ or c# but didnt find the right place to post this.. so here goes..
Currently doing a project on c,
aim is to retrived certain field from a .txt file..
my question is do i need to create a structure for that txt file..
if not.. how do i skip a field when readin from a .txt file.??
etc of what in the .txt file
[clientA] [id] [password]
[clientB] [id] [password]
i wanna retrieve the id and password only..
so far i only wanna to opent eh file and print all the info out..
can i use fscanf to do it.
tks guys
the problem i face nw is that the info in the txt file is of different length.
etc.. the clientA name can be 10char n b is 15 char.
i manage to read the strinf from the .txt file and store it into a array[200];
i was tinkin to try to seprate the id and password and store them into different array and use strcmp to check with the user input.
etc from .txt
peter 1111 abcdef
michard 1112 cccbefj
so im tryin to get the id ( 1111 and 1112) out and password abcdef and cccbefj
but im really having a hard time doing so..
|
|
|
|
|
this is what i wrote.. pardon me for such stupid programmin..
#include<stdlib.h>
#include<stdio.h>
#include<io.h>
#include<fcntl.h>
#define EOF (-1)
char passwordchk(char id[],char pw[]);
main()
{
char pw[10];
char id[10];
printf("id:");
gets(id);
printf("\npassword:");
gets(pw);
printf("\nThis if for testing purpose..id=%s\tpw=%s",id,pw);
passwordchk(id,pw);
getchar();
}
char passwordchk(char id[],char pw[])
{
FILE *f;
int i;
int c,count=0;
char buffer[200];
char checker[200];
char id_one[3];
char id_two[3];
char id_three[3];
char one_pw[6];
char two_pw[6];
char three_pw[6];
printf("\nstuff that is pass over to pw function %s,%s\n",id,pw);
f = fopen("passwd.txt", "rt");
while((c=fgetc(f))!=EOF)
{
buffer[count]=c;
count++;
}
printf("\nFrom buffer\n%s",buffer);
fclose(f);
}
|
|
|
|
|
I love C, it is so simple.
If the file was written using structures, then read it using structures of the same size. Now writing it and reading it does involve structure alignment, but that is no different than any other object/record reading. If the file was created specifically to be read as ‘.txt’ then you sill need to know the format and then read it a line at a time
Look at the problem and do not try to over complicate it. The simplest solution is usually the best solutions.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
I actually start try out declaring the structure but i got stuck in the mids of doing.
struct record
{
char name[10],personID[10],password[10]
};
this is how i declared.. but the problem is assume the size of password is fix so that ok, i can declared a static one.. but for the pass word and the name.. that can be a problem
etc .txt
peter 1111 abc124
michard 1342 stbjllll
michelle 2312 vjhbvk
so im stucked... i just wanna be able to retieve the id and password from the .txt file then compare it with the user input to check if it correct..
|
|
|
|
|
Looks like ‘Iain Clarke’ gave a reasonable answer to your problem.
As for using structure/record type of format, you would have to place some restrictions on the field sizes, as you have discovered. But since you are dealing with a ‘.txt’ file, attempting to read it using a structure would be a bad idea, as it does not meet the requirement of structured data. Unstructured text data, in the form you presented, should probably be read one line at a time (kind of slow), parsed, and stored internally in any form you wish, including an array of records/structures.
The following is just for my entertainment, but it may give you some ideas:
enum my_field_sizes { REC_NSIZE=32, REC_IDSIZE=10, REC_PWSIZE=12};
typedef struct my_record
{
char name[REC_NSIZE], id[REC_IDSIZE], pw[REC_PWSIZE];
} MY_RECORD;
const char* My_ReadField(const char* pStr, char* pOut, unsigned nOutSize)
{
if( pStr && *pStr && pOut && nOutSize )
{
int i;
while( isspace(*pStr) )
++pStr;
for( i=0; i < nOutSize && !isspace(*pStr) && *pStr; ++i, ++pStr )
pOut[i] = *pStr;
i = (i < nOutSize) ? i : (nOutSize-1);
pOut[i] = ‘\0’;
while( !isspace(*pStr) && *pStr )
++pStr;
}
return(pStr);
}
void My_ReadRecordLine(MY_RECORD* pRec, const char* pLine)
{
const char* pNextField = pLine;
memset(pRec, 0, sizeof(MY_RECORD));
pNextField = My_ReadField(pNextField, pRec->name, REC_NSIZE);
pNextField = My_ReadField(pNextField, pRec->id, REC_IDSIZE);
My_ReadField(pNextField, pRec->pw, REC_PWSIZE);
}
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|