|
do SaveDC/RestoreDC work the same?
Yes, RestoreDC should de-select objects selected after SaveDC. The real question is: what's the performance impact of SaveDC/RestoreDC? Without a profiler session, I can't give you any real advice. I think that using SaveDC/RestoreDC in small functions called in tight loops could cripple the performance, but that's only a guess.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
That's what we thought and we always select the saved objects before leaving the scope. But the thing just wasn't working in Windows 95. It only worked after we excplicitly called DeleteObject().
|
|
|
|
|
Hello !!
I want to take the system into sleep state aand wake the system after say 10 seconds..
I am using the API SetSystemPowerState(). I have used Setwaitabletimer for 10 seconds to fire an signal after 10 seconds so as to wake the system and come out of sleep state.The system is going into sleep state and then returning from sleep after 10 seconds(indicator lights on the monitor changes but nothing appears on the screen) but nothing on the screen is visible afterwards. Only when I press a key or move the mouse does the monitor gets refreshed. Is there some problem in the permissions set???
Can you please help.
I have used the following:
OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,&hToken));
LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME ,&tkp.Privileges[0].Luid);
AdjustTokenPrivileges(hToken,FALSE,&tkp,sizeof(TOKEN_PRIVILEGES), &oldtp&dwSize);
Sandeep
|
|
|
|
|
Could it be a systems setting?
I remeber of something like "Restore desktop after sleep/suspend mode" for NT4 and Win95. (Don't know the exact option, I'm Italian).
It should be somewhere in the PowerSavings options.
Paolo
|
|
|
|
|
When I create a Dialog Based Application the second dialog of the wizard allows me to choose the language of my resource file. I get the default of US English and choices of Spanish and others.
Later if I add other dialogs to the same project they are defined as Australian resources and placed in another section of the RC file.
What I want to know is how do I get Australian English into the wizard?
Should I make all the resources US English?
If so how? It just magically makes them Australian.
I know I could manually edit the RC file and move them to which ever section I desire, but this in a pain in the arse I can do wihtout. What do others do about this? Or doesn't anyone else worry about this and leave it to the default dished out?
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
Right click on any resource (dialog, menu, whatever) in the Resource View, then select properties. There's a combobox with languages - just select the appropriate one. VC++ uses your locale settings as the default value.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Tomasz
thanks very much for the help, that's two in a row now, it might become a habit. This seems to be one of those little things that someone who has used VC++ since 1995 circa Version 4 should already know, but I don't.
Are these tricks something that you found by trial and error, someone showed you or there's a list of them somewhere.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
Hi,
I need BCGLibrary version 5.1 for my final essay. I'd like to add some functions into BCGlibarary myself but later versions doesn't have source. Do you have it?
Thank in advance
Ngo Khai Hoa
|
|
|
|
|
|
Hi,
I may have a solution to your problem. When Stas I was very sad because as I am only 16 I wasn't able to meet the price he wanted for the software. But lucky for me I had a read of his registration page to see what the price was. As I was reading through I came to three registration forks (on the page http://www.bcgsoft.com/register.htm): Commercial (full price), Shareware (discount), Freeware / Student Developer (FREE) <- Do you hear? FREE!
So you can get the full software (along with the source) for nothing. There are only two conditions - You must be student (which it sounds like you are, [and who care anyway?]), and you put a little note in your splash screen that goes something like 'Bits of this software were mad by Stas Leven' or something.
I hope thats helpful
Joel Holdsworth
'My cup of tea's caught fire!'
|
|
|
|
|
Hi,
I may have a solution to your problem. When Stas I was very sad because as I am only 16 I wasn't able to meet the price he wanted for the software. But lucky for me I had a read of his registration page to see what the price was. As I was reading through I came to three registration forks (on the page http://www.bcgsoft.com/register.htm): Commercial (full price), Shareware (discount), Freeware / Student Developer (FREE) <- Do you hear? FREE!
So you can get the full software (along with the source) for nothing. There are only two conditions - You must be student (which it sounds like you are, [and who care anyway?]), and you put a little note in your splash screen that goes something like 'Bits of this software were mad by Stas Leven' or something.
I hope thats helpful
Joel Holdsworth
'My cup of tea's caught fire!'
|
|
|
|
|
Using MFC VC++ 6, CHTTPConnection and CInternetSession.
Anyone have examples on how to get an html page over an SSl connection i.e. https://myserver/ssl/getdata.asp
I'm using GetHttpConnection and OpenRequest methods on the above objects.
Thx
|
|
|
|
|
There is a flag INTERNET_FLAG_SECURE, which you can pass to CHttpConnection::OpenRequest(). Article Q168151 could help as well.
One and only example I know about SSL is from Platform SDK: \Samples\WinBase\Security\SSL.
Regards,
Martin
|
|
|
|
|
Does anyone have an "Easy" way of hiding the menu bar that appears in an MDI. I need to be able to programatically bring up and down the menu. Ie. for example hiding the menu bar at program start and then having a "special" hotkey to enable the menu. Thanks for any help
|
|
|
|
|
If you're not using MFC, this is enough to hide the menu:
SetMenu(hwnd, NULL);
DrawMenuBar(hwnd);
With MFC, you will have to override CDocument::GetDefaultMenu or CMDIChildWnd::OnUpdateFrameMenu.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thanks for the help I've been able to get this far:
void CMainFrame::OnButtonKillmenu()
{
// Remove and destroy the old menu.
SetMenu(NULL);
CMenu* old_menu = CMenu::FromHandle(m_hMenuDefault);
old_menu->DestroyMenu();
m_hMenuDefault = NULL;
gbMenuBar = false;
}
void CMainFrame::OnButtonRestoremenu()
{
// Load the new menu.
m_NewMenu.LoadMenu(IDR_MFCTYPE);
ASSERT(m_NewMenu);
// Add the new menu
SetMenu(&m_NewMenu);
// Assign default menu
m_hMenuDefault = m_NewMenu.GetSafeHmenu(); // or m_NewMenu.m_hMenu;
DrawMenuBar();
gbMenuBar = true;
}
This allows a button to remove/restore the menu bar but when I use a hot-key (ie. Cntrol->N for a new Document) The menu bar returns. Any ideas?
|
|
|
|
|
This should work in MFC app:
class CChildFrame : public CMDIChildWnd
{
void OnUpdateFrameMenu(BOOL bActivate, CWnd* pActivateWnd, HMENU hMenuAlt);
};
void CChildFrame::OnUpdateFrameMenu(BOOL bActivate, CWnd* pActivateWnd, HMENU hMenuAlt)
{
if (m_bNoMenu)
{
GetMDIFrame()->SetMenu(NULL);
}
else
{
CMDIChildWnd::OnUpdateFrameMenu(bActivate, pActivateWnd, hMenuAlt);
}
}
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hey. Im trying to use structs with a phone book and im getting errors in pfile .. if you can tell me what I'm doing wrong or what is exactly wrong, I would greatly appreciate it.
thanks
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#define MAX 50
struct Phone_record
// declare all variables
{
char fname[MAX];
char lname[MAX];
char category[MAX];
char phonenumber[MAX];
int count;
};
struct Phone_list
{
int count; // keeps rack of number of ppl in list
struct Phone_record pr[MAX];
};
void displaymenu(void);
void choices(void);
void add_record(struct Phone_record *);
void del_record(struct Phone_list *);
void save_record(struct Phone_record *);
void load_record(struct Phone_record *);
void print_record(const struct Phone_record *);
void displaymenu()
{
printf( "A-Add a Phone Number\n"
"D-Delete a Phone Number\n"
"S-Save the phone book\n"
"L-Load the phone book\n"
"P-Printf the Phone List\n"
"Q-Quit the program\n"
"H-Help Menu\n");
}
void choices(void)
{
struct Phone_record pst;
char pick='x';
pst.count=0;
// scanf("%c",&pick);
printf("\n\nPlease make your selection: \n\n");
while (pick!='Q')
{
scanf("%c",&pick);
switch (pick)
{
case 'A':
add_record(&pst);
break;
case 'D':
//del_record();
break;
case'S':
save_record(&pst);
break;
case'L':
load_record(&pst);
break;
case 'P':
print_record(&pst);
break;
case 'H':
displaymenu();
break;
case 'Q':
break;
default:
printf("your choice was invalid\n\n");
break;
}
}
}
void add_record(struct Phone_record *pst)
{
printf("pleaes enter the last name\n");
scanf("%s",pst->lname);
printf("please enter the first name\n");
scanf("%s",pst->fname);
printf("plese enter a category\n");
scanf("%s",pst->category);
printf("plese enter your phone number\n");
scanf("%s",pst->phonenumber);
}
void del_record(struct Phone_list *book)
{
printf("deleting the record");
}
void save_record(struct Phone_record *pst)
{
// pfile=fopen("c:\\myfile.txt","w");
/*fprintf(file,"%d\n",(*book.count));
for i=0; i<(*book).count; i++);
{
fprintf("file,%s\n",(*book.Phone_list[i].name);
fprintf("file,%s\n",(*book.Phone_list[i].category);
fprintf("file,%s\n",(*book.Phone_list[i].phonenumber);
}
*/
}
void load_record(struct Phone_record *pst)
{
pfile=fopen("c:\\myfile.txt","r");
fscanf(pfile,"%d",&(pst.count);
for (i=0; i<pst.count; i++;)
="" {
="" fscanf(pfile,"%s="" %s",pst[i]-="">fname, pst[i]->lname);
fscanf(pfile,"%s",pst[i]->category);
fscanf(pfile,"%s",pst[i]->phonenumber);
}
}
void print_record(const struct Phone_record *pst)
{
printf(" your name is %s %s\n",pst->fname, pst->lname);
printf("your category is %s\n",pst->category);
printf(" your phone number is %s\n",pst->phonenumber);
choices();
}
int main (int argc, char*argv[1])
{
FILE *pfile=NULL; // File Pointer
struct Phone_record;
int i;
pfile=fopen("C:\\myfile.txt","w");
printf("Welcome to the Phone Book");
printf("\n\n");
displaymenu();
choices();
fclose(pfile);
return 0;
}
|
|
|
|
|
What error are you getting and where? Just glancing through your code, the only thing that catches my eye is that your not doing a fclose(pfile) in load_record.
|
|
|
|
|
ok here are the errors
C:\cprogram\Hw6.c(106) : error C2065: 'pfile' : undeclared identifier
C:\cprogram\Hw6.c(106) : warning C4047: '=' : 'int ' differs in levels of indirection from 'struct _iobuf *'
C:\cprogram\Hw6.c(107) : error C2065: 'file' : undeclared identifier
C:\cprogram\Hw6.c(107) : warning C4047: 'function' : 'struct _iobuf *' differs in levels of indirection from 'int '
C:\cprogram\Hw6.c(107) : warning C4024: 'fprintf' : different types for formal and actual parameter 1
C:\cprogram\Hw6.c(107) : error C2065: 'book' : undeclared identifier
C:\cprogram\Hw6.c(107) : error C2224: left of '.count' must have struct/union type
C:\cprogram\Hw6.c(108) : error C2061: syntax error : identifier 'i'
C:\cprogram\Hw6.c(108) : error C2065: 'i' : undeclared identifier
C:\cprogram\Hw6.c(108) : error C2100: illegal indirection
C:\cprogram\Hw6.c(108) : error C2224: left of '.count' must have struct/union type
C:\cprogram\Hw6.c(108) : error C2059: syntax error : ')'
C:\cprogram\Hw6.c(110) : warning C4133: 'function' : incompatible types - from 'char [9]' to 'struct _iobuf *'
C:\cprogram\Hw6.c(110) : error C2224: left of '.Phone_list' must have struct/union type
C:\cprogram\Hw6.c(110) : error C2143: syntax error : missing ')' before ';'
C:\cprogram\Hw6.c(110) : error C2198: 'fprintf' : too few actual parameters
C:\cprogram\Hw6.c(111) : warning C4133: 'function' : incompatible types - from 'char [9]' to 'struct _iobuf *'
C:\cprogram\Hw6.c(111) : error C2224: left of '.Phone_list' must have struct/union type
C:\cprogram\Hw6.c(111) : error C2143: syntax error : missing ')' before ';'
C:\cprogram\Hw6.c(111) : error C2198: 'fprintf' : too few actual parameters
C:\cprogram\Hw6.c(112) : warning C4133: 'function' : incompatible types - from 'char [9]' to 'struct _iobuf *'
C:\cprogram\Hw6.c(112) : error C2224: left of '.Phone_list' must have struct/union type
C:\cprogram\Hw6.c(112) : error C2143: syntax error : missing ')' before ';'
C:\cprogram\Hw6.c(112) : error C2198: 'fprintf' : too few actual parameters
Error executing cl.exe.
im not sure if i am loading and saving the recods right .. i put a
fclose(pfile) in load record..
here is the code again
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#define MAX 50
struct Phone_record
// declare all variables
{
char fname[MAX];
char lname[MAX];
char category[MAX];
char phonenumber[MAX];
int count;
};
struct Phone_list
{
int count; // keeps rack of number of ppl in list
struct Phone_record pr[MAX];
};
void displaymenu(void);
char choices();
void add_record(struct Phone_record *);
void del_record(struct Phone_list *);
void save_record(struct Phone_record *);
void load_record(struct Phone_record *);
void print_record(const struct Phone_record *);
void displaymenu()
{
printf( "A-Add a Phone Number\n"
"D-Delete a Phone Number\n"
"S-Save the phone book\n"
"L-Load the phone book\n"
"P-Printf the Phone List\n"
"Q-Quit the program\n"
"H-Help Menu\n");
}
char choices()
{
struct Phone_record pst;
char pick='x';
pst.count=0;
// scanf("%c",&pick);
printf("\n\nPlease make your selection: \n\n");
while (pick!='Q')
{
scanf("%c",&pick);
switch (pick)
{
case 'A':
add_record(&pst);
break;
case 'D':
//del_record();
break;
case'S':
save_record(&pst);
break;
case'L':
load_record(&pst);
break;
case 'P':
print_record(&pst);
break;
case 'H':
displaymenu();
break;
case 'Q':
break;
}
}
return pick;
}
void add_record(struct Phone_record *pst)
{
printf("pleaes enter the last name\n");
scanf("%s",pst->lname);
printf("please enter the first name\n");
scanf("%s",pst->fname);
printf("plese enter a category\n");
scanf("%s",pst->category);
printf("plese enter your phone number\n");
scanf("%s",pst->phonenumber);
}
void del_record(struct Phone_list *book)
{
printf("deleting the record");
}
void save_record(struct Phone_record *pst)
{
pfile=fopen("c:\\myfile.txt","w");
fprintf(file,"%d\n",(*book.count));
for i=0; i<(*book).count; i++);
{
fprintf("file,%s\n",(*book.Phone_list[i].name);
fprintf("file,%s\n",(*book.Phone_list[i].category);
fprintf("file,%s\n",(*book.Phone_list[i].phonenumber);
}
}
void load_record(struct Phone_record *pst)
{
/* pfile=fopen("c:\\myfile.txt","r");
fscanf(pfile,"%d",&(pst.count);
for (i=0; i<pst.count; i++;)
="" {
="" fscanf(pfile,"%s="" %s",pst[i]-="">fname, pst[i]->lname);
fscanf(pfile,"%s",pst[i]->category);
fscanf(pfile,"%s",pst[i]->phonenumber);
}
fclose(pfile);
*/
}
void print_record(const struct Phone_record *pst)
{
printf(" your name is %s %s\n",pst->fname, pst->lname);
printf(" your category is %s\n",pst->category);
printf(" your phone number is %s\n",pst->phonenumber);
choices();
}
void display_command_line(int number_of_parameters, char * parameter[])
{
int i;
printf("There (is/are) %d parameter(s):\n",number_of_parameters);
for(i=0;i
|
|
|
|
|
Oh! Well you kind of need to declare your variables. When you declare your variables in your main, they are local variables in the main function, your other functions don't see them, as they are created on main's stack and not globally on the heap. For example, just because you declare "int i" in main() does not mean that you do not need to do it again in save_record.
|
|
|
|
|
Hey folks,
In the application that I'm writing, I have to resize an image then reduce the number of colours in it. I have got the resizing done OK - and have a few ideas for the colour reduction algorithm but the problem is they seem to be very inefficient. I was wandering if anyone had any good ideas as to quick algorithms - perfection is not necessary, I would say speed is more important, as long as the colours selected are visibly near.
I've read the article in MSJ (quite an old issue) about colour quantization but the problem is, this only provides a palette, where I need a new image to be produced with the new colours in the correct place etc, as the image will be stored in memory for further processing. Not asking much, eh? . BTW - don't worry Christian, I ain't planning GrausPaint XP (or anything like it for that matter, it's purely one part of a larger application).
cheers,
Andrew.
|
|
|
|
|
Try the Intel Image processing Library (IPL) or alternately the Image processing portion of the Intel Processing Primitives (IPP). I have used both and find them very efficient (they're optimized to exploit SIMD and SIMD2 on the P3/P4 respectively). They also have a ton of other canned functions you can use (rotate, zoom, filters of all kinds including the ability to use your own filter kernels, FFT's, DCT's, wavelets, etc. etc.).
The IPL interfaces very nicely to a windows DIB.
Give it a shot.
Al
--
|
|
|
|
|
Wavelets are available on the Intel Signal Processing Library (SPL) or the signal processing portion of the IPP, not on the Image processing libraries. The SPL is only suitable for single channel stuff (complex signals from comms. receivers and the like) instead of image data - 3 channel RGB data.
|
|
|
|
|
...there are lots of image processing libs around. i prefer ImgSource.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|