|
Generic approach is
BOOL cxx::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_RETURN )
{
return TRUE;
}
return CEdit::PreTranslateMessage(pMsg);
}
For CEdit to get VK_RETURN you need to add style ES_WANTRETURN
Brian
|
|
|
|
|
Brian Shifrin wrote:
Generic approach is
BOOL cxx::PreTranslateMessage(MSG* pMsg)
It sure worked with your recommended PreTranslateMessage().
Many thanks.
|
|
|
|
|
The following code is from MSDN MAPI sample:
after compiling and running it's giving error:
Any help on this...
#include "stdafx.h"
#include "mapix.h"
#include "mapiutil.h"
HRESULT GetMAPIStatus(LPMAPISTATUS *pStatus, LPMAPISESSION pSession);
int main(int argc, char* argv[])
{
LPMAPISESSION pSession = NULL; //MAPI Session Pointer
LPMAPISTATUS pStat=NULL; //MAPI Status Pointer
HRESULT hRes = S_OK;
//Initialize MAPI.
hRes = MAPIInitialize(NULL);
//Log on to MAPI and get a session pointer.
hRes = MAPILogonEx(0, NULL, NULL, MAPI_LOGON_UI | MAPI_NEW_SESSION, &pSession);
//hRes = MAPILogonEx(0, "umakanthch", "chepuri_uk", MAPI_LOGON_UI | MAPI_NEW_SESSION, &pSession);
if (hRes == S_OK && pSession) //if logon OK get a status pointer.
{
//Call function to get the status pointer.
hRes = GetMAPIStatus(&pStat, pSession);
if(hRes == S_OK && pStat) //if we successfully got a status pointer call FlushQueues on it.
{
//Flush inbound and outbound messages.
hRes = pStat->FlushQueues(NULL, 0, NULL, FLUSH_UPLOAD | FLUSH_DOWNLOAD);
if(hRes == S_OK)
MessageBox(NULL, "FlushQueues OK!", "FlushQueues", MB_OK);
else
MessageBox(NULL, "FlushQueues Failed!", "FlushQueues", MB_OK);
}
else
MessageBox(NULL, "GetMAPIStatus Failed!", "FlushQueues", MB_OK);
pSession->Logoff(NULL, 0L, 0);
}
else
{
MessageBox(NULL, "MAPI Logon Failed!", "FlushQueues", MB_OK);
}
//Clean up pointers.
UlRelease(pStat);
UlRelease(pSession);
MAPIUninitialize();
// MessageBox(NULL, "End of MAPI ", "FlushQueues", MB_OK);
return 0;
}
/////////////////////////////////////////////////////////////////
// Gets the spooler's status object from the session status table.
/////////////////////////////////////////////////////////////////
HRESULT GetMAPIStatus(LPMAPISTATUS *pStat, LPMAPISESSION pSession)
{
LPMAPITABLE pTbl = NULL;
LPSRowSet pRow = NULL;
HRESULT hRes;
SRestriction sres;
SPropValue spv;
ULONG ulObjType;
int cbEID;
LPENTRYID pbEID;
const static SizedSPropTagArray(2,sptCols) = {2,PR_RESOURCE_TYPE,PR_ENTRYID};
if (FAILED(hRes = pSession -> GetStatusTable(0,&pTbl)))
{
MessageBox(NULL, "GetStatusTable Failed!", "GetStatusTable", MB_OK);
goto Quit;
}
sres.rt = RES_PROPERTY;
sres.res.resProperty.relop = RELOP_EQ;
sres.res.resProperty.ulPropTag = PR_RESOURCE_TYPE;
sres.res.resProperty.lpProp = &spv;
spv.ulPropTag = PR_RESOURCE_TYPE;
spv.Value.l = MAPI_SPOOLER;
if (FAILED(hRes = HrQueryAllRows(pTbl,
(LPSPropTagArray) &sptCols,
&sres,
NULL,
0,
&pRow)))
{
MessageBox(NULL, "HrQueryAllRows Failed!", "HrQueryAllRows", MB_OK);
goto Quit;
}
if (!pRow -> cRows || PR_ENTRYID != pRow -> aRow[0].lpProps[1].ulPropTag)
{
hRes = MAPI_E_NOT_FOUND;
MessageBox(NULL, "HrQueryAllRows Failed!", "HrQueryAllRows", MB_OK);
goto Quit;
}
hRes = pSession -> OpenEntry(pRow -> aRow[0].lpProps[1].Value.bin.cb,
(LPENTRYID)pRow -> aRow[0].lpProps[1].Value.bin.lpb,
NULL,
MAPI_BEST_ACCESS,
&ulObjType,
(LPUNKNOWN *)pStat);
if (FAILED(hRes))
{
hRes = hRes ? hRes : MAPI_E_INVALID_OBJECT;
MessageBox(NULL, "OpenEntry Failed1!", "OpenEntry1", MB_OK);
goto Quit;
}
/*if (FAILED(hRes) || MAPI_STATUS != ulObjType)
{
hRes = hRes ? hRes : MAPI_E_INVALID_OBJECT;
MessageBox(NULL, "OpenEntry Failed!", "OpenEntry", MB_OK);
goto Quit;
}*/
Quit:
if (pTbl)
pTbl -> Release();
FreeProws(pRow);
return hRes;
}
Thank you
|
|
|
|
|
Ok, let me try to explain what's going on. I have a CView on that view I create multiple instaces of a control that I have created via subclassing a CDialog. The creation of the instances is done via the Create(IDD_MYCONTROL, this) function. Let's call that CMyControl. In every instance CMyControl I use a timer via SetTimer(0, 100, NULL);. The problem is that the timers of each CMyControl influence each other. How is that possible and how can ik fix that? By influence I mean that if I have 4 instances the timers do not work anymore but if I have 3 instances the timers work.
Greetings Dennis.
|
|
|
|
|
The main reason ist that the timer ID are global, so every object gets the ID send. To resolve this you must give them different IDs. For instance use a global function to get the next timer ID:
int GetNextTimer()
{
return ++gTimerIds;
}
Try this @ home. (B&B)
|
|
|
|
|
i have a server which imitates the Windows I/O Completion port technology(for the 9x machines)by using WSASend() and WSARecv() functions
My problem is that , the Socket event which i get
is raised only when the time of fixed size is recived,
for eg: i send the packet of size 4k from cllient to server,
if the packet is exact 4k then the server scoket event raised and i can read the data, if the packet is 1k each, thatt event will not raised, that only raised when the 4k rached (4 * 1 KB s), bcz of this i can't read the prevous 3 packet datas..
Any solution?????
CodeTheDreams();
|
|
|
|
|
The problem occurs because the sender side delays the delivery of the transmitted packet until the configured data packet size would be reached.
Try to call setsockopt with TCP_NODELAY and check that you don't use MSG_PARTIAL flag in call to WSASend.
|
|
|
|
|
Do you mean IOCP does not update the process until there is exactly 4k in the buffer? Post a WSARecv() and see if it returns with new data immediately.
Kuphryn
|
|
|
|
|
Hi, everyone!
I want to read some data from a word file. The file
contains text, table and images. I want to get some
data from the table and text.
How to do that? Are there some tutorials or sample codes?
Thanks in advance,
George
|
|
|
|
|
Read a Microsoft Office Developer's Guide. The word file and enclosed items can be accessed through MS-Word COM object model.
|
|
|
|
|
Thanks, Yuri buddie!
George
|
|
|
|
|
Which function(s) are called when loading the values from the resource.h file of a dialog application? Or how to load these values at runtime?
|
|
|
|
|
In the resource.h are only the values as macros defined. The resources reside in a *.rc file as data or as link (*.bmp).
The loading depends on the type of object. Bitmaps are loading with the CBitmap class.
Please read the MSDN or CP-Websites.
Try this @ home. (B&B)
|
|
|
|
|
Hi!
My source code seems has a memory leak, the MFC Debug mode can tell me the position in memory address and its size.
My question is how can i get its position in source code or the other info that will help me to find the wrong code?
Thanks!!
|
|
|
|
|
|
|
I'd like to write a program that calculates something but still allows messages to be processed. Essentially I want to write an MFC OpenGL app. Where do I put my function calls? I know I need to create a different thread, but does this mean writing my own class, inheriting it from CWnd and then have it be an object under my Dialog and receive messages from the parent Wnd?
|
|
|
|
|
Check out MFC sample MTRECALC.
|
|
|
|
|
i was studying c++ object oriented programming notes today and have some questions regarding to this problem.. any suggestion is welcome.. thank you!
for this question, i'm supposed to find the implementation error and fix it without changing the interface.
i read thru the codes and realized that the method B::Init() was trying to initialize the private variable, pNum, that belongs to class A(Class B's super class).. I was wondering is there anyway to access to class A's private variable from class B? and also have i missed any other implementation error?
class A
{
public:
A() { Init(); }
virtual ~A() { Destroy(); }
virtual void Init();
virtual void Destroy();
long Get() { return *pNum; }
void Set(long num) { *pNum = num; }
private:
long *pNum;
};
class B : public A
{
public:
B() { Init(); }
virtual ~B() { Destroy(); }
virtual void Init();
virtual void Destroy();
long Get2() { return *pNum; }
void Set2(long num) { *pNum = num; }
private:
long *pNum2;
};
void A::Init()
{
pNum = new long;
}
void A::Destroy()
{
delete pNum;
}
void B::Init()
{
pNum = new long;
pNum2 = new long;
}
void B::Destroy()
{
delete pNum2;
}
|
|
|
|
|
B cannot see A's privates. If you made the variable protected, it would be visible to B. Otherwise you can make B a friend class of A, but in this case that would be kind of redundant, unless A has other classes derived from it which should be disallowed from seeing A's private stuff.
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
I feel real dumb for having to resort to this but I cannot find what I need to know anywhere.
In an MFC App (VS.NET)I have a button in my dialog box. I thought that when I double click it in design view it would generate the code for the button click event -- then all I would have to do is fill in the code (VS does this on the computers at school). But (at home) when I double click a button in design view Visual Studio gives me the MFC Add Class wizard. I tried adding the code by hand but it didn't work. I think the event I wrote by hand didn't get attached to my button. Anyway...is there a setting in Visual Studio that will chanage this so that when I double click a button in design view the code for a button click event will be generated??
Thanks for you help!
"It has become appallingly obvious that our technology has exceeded our humanity."
- Albert Einstein (1879-1955)
"I think there is a world market for maybe five computers."
- Thomas Watson (1874-1956), Chairman of IBM, 1943
"640K ought to be enough for anybody."
- Bill Gates (1955-), in 1981
"Half this game is ninety percent mental."
- Yogi Berra
|
|
|
|
|
I guess you haven't associated a class with your dialog resource. First you need to do that - associate a CDialog derived class with the dialog resource; only after that will dbl-clicks on control result in their mouse click handlers getting automatically created for you
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Ok I did that and it gives me the event but i created a new header file and cpp file. I want the event to be generated in my ...View.cpp file without it creating a seperate .h and .cpp
Do you know how to do that?
"It has become appallingly obvious that our technology has exceeded our humanity."
- Albert Einstein (1879-1955)
"I think there is a world market for maybe five computers."
- Thomas Watson (1874-1956), Chairman of IBM, 1943
"640K ought to be enough for anybody."
- Bill Gates (1955-), in 1981
"Half this game is ninety percent mental."
- Yogi Berra
|
|
|
|
|
How can i understand one program is terminated?
for example suppose the NOTEPAD.EXE is running ,now i want to be notified whenever
that it is terminated? It is very important for me to understand.Please Help Me.
Please excuse me for bad comments,my english isn't well.
Thanks a lot.
|
|
|
|
|
If you have it's process handle, you can wait on the handle using one of the WaitForXXXX API calls.
Else if you have the HWND of the window, just do an IsWindow on it and then do a GetWindowText etc... and verify that it;s the same window.
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|