|
My goal is similar to how Visual Studio opens Project and Workspace files: those file types are associated with VS, but they don't open up Views in the middle of the screen, they just fill in some information. I want to imitate this for opening Projects in my application.
thanks,
Jake
|
|
|
|
|
I have two problem here.I read image field from database and want to show it on my formview.I use this code:
COleVariant var;
var.vt = VT_UI1;
var = field.GetChunk(field.GetActualSize());
BITMAPINFO bmInfo;
memset(&bmInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));
bmInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
bmInfo.bmiHeader.biWidth=120;
bmInfo.bmiHeader.biHeight=120;
bmInfo.bmiHeader.biPlanes=1;
bmInfo.bmiHeader.biBitCount=24;
HDC pDC = ::GetDC(0);
HDC TmpDC= CreateCompatibleDC(pDC);
HBITMAP TmpBmp=CreateDIBSection(pDC,&bmInfo,DIB_RGB_COLORS,(void**)&var,0,0);
HGDIOBJ TmpObj=SelectObject(TmpDC,TmpBmp);
CRect rect;
GetClientRect(&rect);
int nX = rect.left + (rect.Width() ) / 3;
int nY = rect.top + (rect.Height() + 500 ) / 2 ;
BitBlt( pDC, nX, nY , 200, 200 , TmpDC , 0 , 0 , SRCCOPY );
Only black rectangle appear on my form.I don't know if the problem from reading data from database or my setting for bitmap has some problem.Those who know bitmaps can tell me if it has correct setting.
My second problem is that I can't put bitmap in correct place.It goes out of the application.How can I manage it correctly?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Just out of curosity, how do you make a CFindReplaceDialog application modal? I noticed that the one that comes with Excel is app modal, but the one I have is not. So, essentially, if you have two workbooks open in excel and open the find dialog on one of them, it doesn't allow you to switch to the other document until you close the dialog. I gather it must be some flag that is set somewhere..any idea what?
|
|
|
|
|
Hey all,
I am trying to research the feasability of putting together a TFTP file upload for reprogramming an embedded system. I am writing the PC side. I realize that TFTP is a protocol and I am going to read the RFC tonight, however I was wondering if anyone has seen an article or source code that shows examples of something like this.
It needs to be supported over RS232 and IP, which should be possible. The biggest hurdle, I think is that my employer wants instant turn around to get the product out the door. So yes I am looking for examples to reduce turn around, if possible.
Thanks,
Brian aka SanShou
|
|
|
|
|
TFTP servers are pretty easy to write - we've used them for downloading software to embedded systems a few times, usually over a proper TCP/IP stack. To use TFTP over RS232, you're going to have to provide an interface to the RS232 link that effectively emulates what the TCP layer would provide (I think) - no biggy, dial-up modem does that.
As to existing software, try looking on a Linux distro - there may be TFTP software on that, with source?
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
I tried to use OnContextMenu and OnRButtonDown to popup the context menu when click right mouse button in a CHtmlView class. When I test it, no menu popup. How to fix it? Thanks.
mIchAel Liu
__________________________________________________________
The secret of business is to know something that nobody else knows.
|
|
|
|
|
OnContextMenu and OnRButtonDown are MFC command handlers. The trouble is that CHtmlView derives from a CView but provides no real support for it. CHtmlView is basically a wrapper around the web browser ActiveX control. You can check out yourself by the way because we have all the code for it.
So all right clicks are in fact consumed by the ActiveX.
The good news is that the web browser control has a mechanism to supersede context menus. You have to implement the IDocHostUIHandler interface. You have built-in samples in MSDN library. (and even in codeproject as far as I remember).
|
|
|
|
|
Thank you. It's a good point.
mIchAel Liu
__________________________________________________________
The secret of business is to know something that nobody else knows.
|
|
|
|
|
Hello there,
I have 10 editbox in my dialog ...
I want to show a message when user pressed enter in the EditBox Number 2(for example) !!!
How can i do that ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Keyboard messages...[^]
This should answer your question.
int x=1, y=5;
x^=y^=x^=y;
<a href="http://www.codeproject.com/useritems/StupidXORTrick.asp" target="_blank">ClickHereForHelp();</a>
|
|
|
|
|
1. Create your own class, say MyEdit.
2. Derive it from CEdit.
3. In my edit add a handler for the message WM_GETDLGCODE message by using the class wizard.
4. The Wizard will add the handler afx_msg UINT OnGetDlgCode() for you.
5.Replace the default return value by return DLGC_WANTALLKEYS;
6.Now in the same way add one more handler for WM_KEYDOWN. nChar value will be 13 for Enter-Key. Handle the Enter-Key event here.
7. Use the new class in your dialog box instead of the CEdit class to get Enter-Key event.
Regards,
Rejeesh
|
|
|
|
|
How can I listen a port and map the OnConnect, OnAccept, OnReceive and OnClose events to the socket that listen the port ??
Any example ??
Thanks,
Cristiano.
|
|
|
|
|
Derive your own Socket class from CSocket, you can then easily react on the On..() event. Here's how I've derived the CSocket class:
#include "stdafx.h"
#include "UDPSocket.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CUDPSocket::CUDPSocket()
{
}
CUDPSocket::~CUDPSocket()
{
}
#if 0
BEGIN_MESSAGE_MAP(CUDPSocket, CAsyncSocket)
END_MESSAGE_MAP()
#endif // 0
void CUDPSocket::SetParent(CFrameWnd *pWnd)
{
m_pWnd = pWnd;
}
void CUDPSocket::OnReceive(int nErrorCode)
{
if (nErrorCode == 0)
((CMainFrame*)m_pWnd)->OnReceive();
}
and the header file:
#if !defined(AFX_UDPSOCKET_H__B455316B_592B_4066_B909_F961153C0A61__INCLUDED_)
#define AFX_UDPSOCKET_H__B455316B_592B_4066_B909_F961153C0A61__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CUDPSocket : public CSocket
{
public:
public:
CUDPSocket();
virtual ~CUDPSocket();
public:
void SetParent(CFrameWnd *pWnd);
protected:
virtual void OnReceive(int nErrorCode);
private:
CFrameWnd* m_pWnd;
};
#endif
You can then, after you have set up the Socket, Listen with
CUDPSocket sock;
sock.Listen();
Hope this helps
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Ok, Gregor ... thanks !!!
One more thing,
.
.
CUDPSocket sock;
//setup the socket
sock.Listen();
.
.
How can I accept a connection ??
Do I need to use Create, Listen and Accept function ?? How ??
How I use the SetParent(CFrameWnd *pWnd) function on my class dialog ?
Thanks again,
Cristiano.
|
|
|
|
|
If you have a dialog based app I suggest you to change CFrameWnd to CDialog. Then, e.g. in OnInitDialog() you simply call socket.SetParent(this);
One again, if you have a dialog you should replace all instances of "CMainFrame" to "CYourDialog" in the derived socket class.
Then you create the functions OnAccept, OnReceive and so on in your dialog class so that the Socket class can redirect the events to your dialog. (That's what ((CMainFrame*)m_pWnd)->OnReceive(); is for).
All you need to do before the Listen() call is to "Create()" your socket.
In the OnAccept() handler inside your dialog (or mainframe class) you simply call socket.Accept(...)
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Ok, its work partially well ...
The OnAccept event (not OnConnect ??) triggered.
But, the OnReceive and OnClose events don't triggered.
Any idea ??
Thanks,
Cris.
|
|
|
|
|
Did you implement them in your derived CSocket class and did you set up similar functions in your Dialog/Mainframe class? If yes, everything should work fine.
Well, don't forget to change all occurances of "CAsyncSocket" to "CSocket" in your derived class
modified 12-Sep-18 21:01pm.
|
|
|
|
|
What do means: "change all occurances of CAsyncSocket to CSocket in your derived class" ??
I changed my derived class to derive from 'CAsyncSocket' and not more 'CSocket', but don't work too. I don't receive the OnReceive and OnClose events.
[]'s
Cris.
|
|
|
|
|
Hi,
I disabled listbox style 'No integral height', but it doesn't work with resizeable dialogs/controls.
Yes, I'd like to see only full visible items. When I resize the dialog, the listbox becomes also resized... and I see partly visible items. It seems 'integral height' is being ignored. What I'm doing wrong?
|
|
|
|
|
|
Hello guys,
I have a question in reagrds to MDIs. I have a MDI application that has 2 different CMDIChildWnd classes. I need both of these classes to be able to access the same variables in the MyDoc or MyView class.
This is what I do know.
I know that if I want to access a variable from the Doc or View class from the default MDI application CMDIChildWnd class (ChildFrm.cpp), then to access these variables I can use GetActiveDocument or GetActiveView.
Here is my problem.
When I open a new window from the CMDIChildWnd class that I added into my project (MyCMDIChildWnd), then it becomes the current Doc/View. So if I use GetActiveDocument on this, I get a return value of NULL.
What I want to do then is to access the variables that the 1st CMDIChildWnd class (ChildFrm) with the second CMDIChildWnd class (MyCMDICHildWnd). How can I do this?
I was thinking that maybe if I assigned a number to each of the windows, then I could always say, "Access the information in ChildFrm, which is window number 1"
Is there a way to enumerate the open windows? Or to access information that the first window opened?
Thanks a whole lot,
NickOne
p.s. If I wrote this all wordy or too confusing, just yell at me and I'll try to rephrase. I am really stuck with this and I want to solve my problem, so any driection or advice could help.
|
|
|
|
|
I'm not sure I understand your question. Do you want the two MDI child windows to use the same document? If so, then put a pointer to the current document into the CCreateContext structure when creating the second MDI child.
This is quite a large subject, so I'd like to know your exact requirement and problem before getting to deep into it.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
1. How do I update a status bar 'field' outside of MainFrame.cpp (where I declared the status bar window)? More specifically, I'm invoking a function in View.cpp and would like that function to update the status bar 'field'.
2. When using the Wizard, you end up with the MFC appln icon. How do I change that? In my resource.rc, I have the following [IDR_MAINFRAME ICON DISCARDABLE "res\\SEI.ico"], which specifies the small icon I want for my appln. The icon, however, does not show. What else do I need to do toward that effect? Thanks,
Ralf.
ralf.riedel@usm.edu
|
|
|
|
|
1. Write public function in CMainFrame which updates status bar by the way you want. You can call this function from any place of your project:
((CMainFrame*)AfxGetMainWnd())->SomeFunction(...);
2. When you edit the icon, don't forget to change both 32x32 and 16x6 versions.
|
|
|
|
|
You can handle messages ON_UPDATE_COMMAND_UI in any window that is child to MainFrame, particularly in your View. Just do not create similar handler in MainFrame, otherwise it will have more priority and your handler will be never called
I disagree with "Alex F" about public method in MainFrame, it breaks the law, that is called "Incapsulation". Plus it increases inflexibility of modules' links
|
|
|
|