|
hello everybody,
(i repost a previous post, but if someone could answer usefully... thx in advance)
i use the following code :
HICON hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_PREVIEW));
CButton* pButton = (CButton*)GetDlgItem(IDC_PREVIEWFACT_BTN);
pButton->SendMessage(BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hIcon);
this code is supposed to set the IDC_PREVIEWFACT_BTN button face with the IDI_PREVIEW icon.
the icon is 16x16 pixels, and the button is bigger (in pixels) than my icon (i cannot say how wuch, because the resource editor don't "speak" in pxls).
my problem is that the ison displays quite "well", except the fact that is is much bigger than the button (so truncated).
does anyone know how to display the icon to its real size ?
thanks in advance...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
From the MSDN docs on LoadIcon:
[quote]
LoadIcon can only load an icon whose size conforms to the SM_CXICON and SM_CYICON system metric values. Use the LoadImage function to load icons of other sizes.
[/quote]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
thank you very much.
i did not notice this detail, but it works fine now.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I have just finished browsing the DLL section on Code Project and I didn't see an answer to the following question.
I am using DLL's as plugins in my application. The DLL's won't have a dialog or anything else viewable. The problems is that I want the dll's to be able to do work without being called.
For example if you have a function in a dll to compute the sum of two numbers. It only computes the sum of these two numbers when you call it.
What if the dll needed to continually be doing some work. One solution I can think of would be to have each dll have a Tick() funcion and call it repeatedly however many times a second you would like it to do its work.
Is there a way to have the dll be a self standing program and do its work when it needs to?
Hope that makes since.
|
|
|
|
|
Hi friend
The DLL is a short for Dynamic Link Library, and because it has the "Linking" behaviour, it must be linked to a program (Executable) or another DLL before it can function --> it can't be standalone.
if you want to run a DLL as a separate process, try using rundll32.exe program.
if the dll needed to continually be doing some work then you can create an internal thread and check for work status.
Regards,
Mohammad Gdeisat
|
|
|
|
|
I don't want it to be standalone. It would be linked at runtime.
Mohammad A Gdeisat wrote:
if the dll needed to continually be doing some work then you can create an internal thread and check for work status.
What do you mean? The dll should create an internal thread?
Here is what I am trying to accomplish.
I have a program this is a front-end for HTPC. I am trying to add all functionality thru
plugin dll's.
So the simple case senario you press a button on the frontend to load a weather module.
The weather module would download weather data, parse it and update this process every 15 minutes.
These dll's need the ability to have the ability to do work without being called expicitly.
|
|
|
|
|
Try CreateThread(...) inside the DLL. (And be prepared for some serious debugging problems.)
A better way would be "idle time processing" - to call a function in the DLL's when the message queue is empty.
|
|
|
|
|
Thanks, I will look into that.
|
|
|
|
|
hi, i have written an activex control in vc++ and now i want to add scroll bars to it as its graphics area is too big and may not fit into users VB Forms. so how can i do this ? thanx
|
|
|
|
|
Hello
Ime writing a program which involves recording from a web cam, but the only tutorials and examples that i can find are much to complicated!!
Does anyone have, or know where to find, a small (simple) program that can record video from a web cam. Preferably just using the windows console so that the program is easier to understand.
Thanks for your help,
Neil
|
|
|
|
|
Try the MSDN example vidcap
"An expert is a person who has made all the mistakes that can be made in a very narrow field." - Neils Bohr
|
|
|
|
|
It's no problem before now. it run correcttly!
But now I'm puzzled with it!
It spend 1~2 seconds to open a table! the light of my computer's hard_disk lasts lighting and makes a big noise at the same time!
Because my Application need to open and close the table frequently !
That's very terrible!
I guess it is not my Application , but what's wrong with it?
with previous thanks!
|
|
|
|
|
How to split dialog with separator
|
|
|
|
|
I am experiencing hard time with memory leak in get_accValue of Active Accessibility, if anyone experienced similar problems before, any help is highly appreciated.
|
|
|
|
|
That's what puzzled me too.
//code:
VARIANT childid;
VariantInit(&childid);
childid.vt=VT_I4;
childid.lVal=CHILDID_SELF;
BSTR val;
hr = pAcc->get_accValue(childid,&val);
CString strVal(val);
SysFreeString(val);
|
|
|
|
|
I'm writing a Windows-XP application that reads a large binary file (more than 3GB) 1MB at a time. I write the data to a DAC card, then go back and read another 1MB from the file. I've malloc'ed 1MB, with a pointer, to store the data. Because this is a real-time DAC application I need the file input to be fast.
I notice that when the file I'm reading is smaller than some limit (about 2.6GB) the file input is fast enough, but when it's at all larger than this limit, it slows down unaccepably. This behavior is very consistent.
I don't think this problem has anything to do with my hard drive or fragmentation of the files. It's too specific to the file size.
I'm using the MFC CFile class to open and read the file:
buffer = (char *) malloc (1048576);
for (i=0; i=3000; i++) {
bytes_read = cfile.Read(buffer, 1048576);
"write to DAC"
}
It's suspicious that the 2.6GB limit is very close to the "available memory" as reported by Windows Task Manager, although I don't see this number change much while the program is running. I'm not trying to read the whole file at once, just 1MB at a time, always overwriting the same 1MB buffer. It's as if it's trying to allocate 3GB and therefore actively paging.
Any ideas would be much appreciated.
Best Regards,
Jason
|
|
|
|
|
For something like this I'd look at using Memory Mapped Files. This should give optimal access to the file and you can just write it directly to your output device. With MMF you don't actually read the file, you access it just like memory. I added MMF support to pugXml which you'll find here on CP.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Thank you. I think that's worth looking into. Long term, though, I might need to read files even bigger than 4GB, which I think is the limit for a memory-mapped file. I thought a "cfile.read" would work, and it seems to work up to a point. It's as if the system is trying to allocate memory for the entire file, even though I'm only reading 1 MB at a time.
Regards,
Jason
|
|
|
|
|
Have you tried profiling the code? I like Glowcode for this. Also have you tried it on another PC, another version of Windows etc.
With MMF I think you can slide a window to different segments of the file so there may not be an issue with file size limits. I've not used this though.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
A few more things. You aren't testing what Read() returns. I think you'll find that CFile can only handle files up to 2G.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Without profiling your code, I can only guess, but I suspect the system is cacheing the file's data (both what you just accessed and look-ahead), and when the cache fills up available memory, the system starts discarding pages and swapping. The result is your program starts having to wait on the disk access, which is far slower than memory.
If that indeed is the cause (again, you need to profile to be sure) then I'd try using CreateFile() with the FILE_FLAG_NO_BUFFERING flag.
--Mike--
LINKS~! Ericahist updated! | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Thanks for your reply. It's just like you said. Judging by the Windows Task Manager, the system is cacheing the file data. As long as the file is smaller than the memory available for the system cache, the execution can keep up. For large files, though, it's getting killed by the swapping.
I switched to FILE_FLAG_NO_BUFFERING. Now I no longer see the system cache filling up, but the transfers have actually slowed down! Does that make any sense?
1. I wrote a loop in which I repeatedly read from the file until the end of the file. It executed fastest when the file was declared as "SEQUENTIAL_SCAN", slowest with "NO_BUFFERING", somewhere in between when "SEQ_SCAN | NO_BUF". I would have expected the last one to be the fastest.
2. I wrote a loop in which I read 1MB into a buffer, then wrote it to a new file. The results weren't conclusive here. I wouldn't be surprised if "NO_BUF" was slower, though. There could be an advantage to cacheing the 1MB of data if you're going to immediately write it back out again.
Please let me know if you have any suggestions.
Best regards,
Jason
|
|
|
|
|
Try overriding CFile:Open and add the FILE_FLAG_NO_BUFFERING (and possibly FILE_FLAG_OVERLAPPED) flag to ::CreateFile().
|
|
|
|
|
Thanks to everyone for your help. Here's an update:
I saw a lot of improvement using "FILE_FLAG_SEQUENTIAL_SCAN".
To use FILE_FLAG_NO_BUFFERING I need to make sure that the buffer is sector aligned. I had been using malloc, but I've switched to VirtualAlloc to control the buffer address alignment. It looks like VirtualAlloc will give me a page-aligned buffer, but is that necessarily sector-aligned? How do I report the sector size? GetDiskFreeSpace will give me that, but only for volumes of less than 2GB.
Regards,
Jason
|
|
|
|
|
Hi ...
i am writing this code to test if there is internet connection :
**********************************************************
void CServerInternetDlg::OnOn()
{
HINTERNET hInternet= ::InternetOpen("BSAtomicEdu", INTERNET_OPEN_TYPE_PRECONFIG , NULL, NULL, 0);
if(!hInternet)
{
AfxMessageBox( "Internet open error! Test your system and try again.", MB_OK | MB_ICONERROR );
return;
}
else
{
AfxMessageBox( "Internet open Success", MB_OK | MB_ICONERROR );
return;
}
}
**********************************************************
but i am getting the following error:
Server InternetDlg.obj : error LNK2001: unresolved external symbol __imp__InternetOpenA@20
Debug/Server Internet.exe : fatal error LNK1120: 1 unresolved externals
**********************************************************
i think i have missing library i am using
#include <afxdb.h>
#include <afxinet.h>
#include <afx.h>
#include <wininet.h>
#include <stdio.h>
#include <tchar.h>
#include <wincrypt.h>
any idea about the error ??!!???
Best Regards
|
|
|
|