|
DavidCrow wrote: So just add a static control, with the SS_BITMAP style, to your dialog's template.
well sir, i did the same. but the static control does not display the bitmap image that i specify. However, is able to display the system icons (like Question mark Icon, or an Information Icon) .
i really dont know what mistake i am doing.
vijay.
|
|
|
|
|
CStatic has a function SetBitmap(that needs to hbitmap) but before it set Type of preperty window to Bitmap
|
|
|
|
|
vijay7173 wrote: i really dont know what mistake i am doing.
And without seeing a relevant code snippet, neither do we.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
vijay7173 wrote: same dialog
But I suggest use of foreign dialog instead same dialog you insert a CDialog to your project and show preview on that dialog if you use of this way you have more control for example you can move this window without any work or change size of show image on the dialog or insert controls to this dialog for control picture,anyway if you want to use this way on the codeproject is more articles
for example search for 3dmax,you can find an article in this article you can see behavior like 3dmax window);)
|
|
|
|
|
no, i dont want to have much features for the preview. i just need to show a thumbnail preview of the image icon selected. i dont want to provide the scaling options either. how can i do it???
vijay.
|
|
|
|
|
One good way is David Crow answer other way is use of WM_ERASEBKGND for show preview of image
|
|
|
|
|
Not problem I think its easy for you but if you have problem and I can help you you can ask;)
|
|
|
|
|
still cant get it work. below is the sample code snippet that isnt working for me.
<br />
CStatic m_ImagstBox[5];<br />
<br />
m_ImagstBox[i].Create(_T("BMP"),WS_CHILD|WS_VISIBLE|SS_ICON|SS_CENTERIMAGE|SS_SUNKEN,CRect(l,50,r,100), this,1001+i); <br />
<br />
m_ImagstBox[i].SetIcon(::LoadIcon(NULL,MAKEINTRESOURCE(IDI_BMP)));<br />
in the above code, IDI_BMP is the id of the icon that i want to display. but i dont know why it is not working. if i specify something like IDI_INFORMATION , then it displays the information icon in the static control.
i even tried the SetBitnap function, to display a bitmap instead of an icon. but could not get it work. below is the sample code that i had written.
<br />
m_st[i].SetBitmap(::LoadBitmap(NULL,MAKEINTRESOURCE(IDB_BITMAP_HOME)));<br />
i am new to MFC and i am sure that i am doing a mistake some where in the code. can u please point out where i am doing the mistake?
vijay.
|
|
|
|
|
You have two ways create CStatic on your code or insert Static control of ToolBox;).
But your problem check this code
m_ImagstBox[0].SetIcon(::LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_BMP)));
And same For SetBitmap
|
|
|
|
|
oh yes, now its working. I have now learnt something from that. thank u.
vijay.
|
|
|
|
|
|
I have this code and it compiles without problems in my VC++ (2003):
Includes omitted.
int main(int argc, char *argv[])
{
SOCKET s;
struct sockaddr_in saddr;
WSADATA wsadata;
short listenport;
int g = 1;
listenport = 25000;
if (WSAStartup(0x202, &wsadata) == SOCKET_ERROR)
{
printf("WSAStartup failed\n");
WSACleanup();
return 0;
}
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s == INVALID_SOCKET)
{
printf("Error opening listen socket\n");
WSACleanup();
return 0;
}
saddr.sin_family = AF_INET;
saddr.sin_addr.s_addr = INADDR_ANY;
saddr.sin_port = htons(listenport);
if (bind(s,(struct sockaddr *)&saddr, sizeof(struct sockaddr_in)) == SOCKET_ERROR)
{
printf("Bind failed\n");
closesocket(s);
s = INVALID_SOCKET;
WSACleanup();
Sleep(1000);
return 0;
}
//more irrelevant code
}
Purpose of program: Read incoming UDP packets (ints, shorts and floats mixed).
Now the question: If I just run the program and listen to port 25000 as in the code it will run through this code. But if I start another (any) program that communicates through UDP on port 25000 I will get "Bind failed" and I don't understand why from all the documentation I've read. I thought it would bind (at least as long as the communication is UDP) no matter what.
I saw the timecli and timeserv demo UDPs in this site and when I look at that code it is so similar that I can't understand why this won't work.
I hope this question is clear.
|
|
|
|
|
Maddack wrote: if (bind(s,(struct sockaddr *)&saddr, sizeof(struct sockaddr_in)) == SOCKET_ERROR)
{
Can you check the error code it is returning ?
|
|
|
|
|
As expected, WSAGetLastError() returned 10048, meaning socket address already in use.
Since I do open the port with another program, that sounds logical. But I thought this would work because I'll just read what is sent out on the port by the server (the other program).
--EDIT--
So I tried changing bind to connect (same arguments and everything). It seems to run through the connect call.
However, after the connect(...) I use the "recv(s,buf,512,0)" function to receive data from the UDP port. For some reason my debug gets stuck at this function.
-- modified at 9:19 Thursday 15th February, 2007
|
|
|
|
|
Maddack wrote: I use the "recv(s,buf,512,0)" function to receive data from the UDP port. For some reason my debug gets stuck at this function.
Sounds like your socket is in blocking mode. You need to use the socket asyncronously.
There are many ways to do this - non-blocking socket mode, overlapped I/O, blocking socket on
a separate thread,...
Great job, team. Head back to base for debriefing and cocktails.
|
|
|
|
|
Hello all,
I need a control to have the focus all the time, but I need also to be able to click other buttons and controls.
What I'm doing now is to place the focus to that control again and again via a OnTimer message handler.
I'd like to know if there is a better approach to do that than:
1. using the timer like now.
2. setting again the focus to that control after pressing any of the other controls that are on the dialog.
The problem here is that if I set the focus to the control then the onclick events that I have in the other controls sometimes fail.
As always thank you in advance.
|
|
|
|
|
What you're proposing isn't practical. Imagine if two programs did it. Each one would constantly steal the focus away from the other (by definition, only one window can have the focus).
|
|
|
|
|
OK, but in my case this is a must: this is an app that loads when a machine start and it is the HMI for the operator of that machine so this is the only program that can be run on the PC. So there is not any possibility of problems with other programs.
By the way, thank you for your feedback.
|
|
|
|
|
I need to copy a file from hard disk to memory and get the physical address of the file in memory
later i feed the physical address to the NIC to initiate DMA transfer
HOW CAN I DO THIS???
pls help
|
|
|
|
|
and no need to repost !!! you can only edit the previous one instead of have several thread on the same topic
|
|
|
|
|
sorry thnks for ur advice!!!
now some one help me in this plsss
|
|
|
|
|
You do not have access to the physical memory addresses in user mode. Only kernel mode drivers can do that.
|
|
|
|
|
HI.
I can't understand something. I have a DLL which has a class that calls a function that is the following:
DWORD dwLen = GlobalSize(m_hDevMode);
BYTE* lp = (BYTE*)GlobalLock(m_hDevMode);
file->Write(&dwLen,sizeof(dwLen));
file->Write(lp,dwLen);
file->Write(&dwLen,sizeof(dwLen));
GlobalUnlock(m_hDevMode);
Now, when I put the .h and .cpp file of the class directly in my application directory and use the class, it works fine. But when I call the class and this function exporting/using it from the DLL, it gives me warnings and does not work. It will comile but when I run the function that calls this function, it does not work.
Can anyone helpl shed some light on this? Or how would I "fix" this?
Thanks ahead of time.
|
|
|
|
|
Stan the man wrote: But when I call the class and this function exporting/using it from the DLL, it gives me warnings
And what are those warnings ?
Stan the man wrote: and does not work.
Can you explain this ?
|
|
|
|
|
Hi!
How do I do to show a picture (.bmp)in a box when I press a key?
For expl. when press key "s" to show the picture1, when press key "d" show picture2, etc. ...
(sorry for my english)
pls help me!
(A small aplication it will very good)
10x
|
|
|
|