|
Do be sorry for my first reply, I've tried my first code, it doesn't work at all, sorry.
I can't see which message do you handle, But you do can ovrride the PreTranslateMessage method to achive your goal.
BOOL CListCtrlEnterKeyDlg::PreTranslateMessage(MSG* pMsg)
{
switch(pMsg->message) {
case WM_KEYDOWN:
if (VK_RETURN == (INT)pMsg->wParam && ::GetFocus() == m_ctlList.GetSafeHwnd())
{
int iSelMask = -1;
iSelMask = m_ctlList.GetSelectionMark();
if (iSelMask != -1)
{
LVITEM lvi = {0};
lvi.iItem = iSelMask;
lvi.iSubItem = 0;
lvi.mask = LVIF_TEXT;
TCHAR szBuf[50] = {0};
lvi.pszText = szBuf;
lvi.cchTextMax = 50;
VERIFY( m_ctlList.GetItem(&lvi) );
::AfxMessageBox(szBuf);
}
}
return TRUE;
default:
break;
}
BOOL bRet = CDialog::PreTranslateMessage(pMsg);
return bRet;
}
I hope this time everything will go fine.^_^
|
|
|
|
|
Thanks it really helps me.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
I have two property pages incorporated in a property sheet.
Property page 1 has a edit control and property page 2 has
a simple push button.
I have overridden the OnApply virtual function for both
the property pages.
When the property sheet is shown, I enable the 'Apply'
button by handling EN_cHANGE notification of the edit
control for Property page 1. On clicking the 'Apply'
button, I show a message defined in overridden OnApply ()
of Property Page 1 and disable the 'Apply' button by
SetModified(FALSE).
Then, I go to Property Page 2 tab and click on the button
on it to enable the 'Apply' button.Now, I click on the 'Apply'
button expecting a message defined in the overridden OnApply()
of Property page 2.
But, I get the message defined in Property Page 1 first and then
get the message in Property page 2.
To summarize, On clicking the 'Apply' button while the
Property page 2 is active, my control is going into the
OnApply() of Property page 1 and then comes into the OnApply()
of Property page 2.
Why is this happening ? Is this the expected behavior ?
Thanks in advance.
|
|
|
|
|
SherTeks wrote: Why is this happening ? Is this the expected behavior ?
This is perfectly fine. The Apply button is on the property sheet, not any individual page.
To borrow a phrase, "what would happen if it only did Apply to the current page?". It's very easy to imagine how things would break down.
If you *really* only wanted it to apply to an individual setting on a page, put a button next to that setting, rather than rely on OnApply. Or you could modify all your OnApply's to check if they're the current page. That's less hard that in sounds - you could have each page inherit from a class inheriting from CPropertyPage called
CMyPropertyPageThatBreaksUserExpectations.
(OK, my opinion is subtly encoded in the name).
I hope this helped,
Iain.
|
|
|
|
|
can any body give me an example code for how to use the function
LsaEnumerateAccountRights() ..
vineesh
|
|
|
|
|
I've just looked on MSDN for the command, and it looks fairly cleanly documented.
http://msdn.microsoft.com/en-us/library/ms721790(VS.85).aspx[^]
You pass it a couple of bits of information, it returns information which you tidy up with LsAFreeMemory.
The hard bits would be generating the SID value, and the Policy object. But if you click on the link, it gives you a nice big example on how to get it.
The below link goes to a page called "Translating between Names and SIDs", taken from the contents of the left of the MSDN site.
http://msdn.microsoft.com/en-us/library/ms722463(VS.85).aspx[^]
I hoped that helped you on your way,
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
convert this way:
WideCharToMultiByte(CP_UTF8,0,pBuf,len,pBuf_MBCS,n,NULL,NULL);
ar.Write(pBuf_MBCS,n);
ar.Close;
It seems all right until I edit the file , and save it again.
The file will be preceded by 3 bytes ahead:
EF BB BF
How to solve it?
Thanks.
system
modified on Thursday, July 10, 2008 1:26 AM
|
|
|
|
|
I am sorry what is the problem? Edit what file and using which editor? If some editor is not saving properly then how is that a programming question?
-Saurabh
|
|
|
|
|
edit the saved file using notepad.exe shipped with windows xp (sp3)
system
|
|
|
|
|
That's the Unicode[^] Byte Order Mask[^] which the editor is inserting. I suggest you make your software handle it.
Steve
|
|
|
|
|
Helpful, thanks.
I choosed to use CP_ACP instead of CP_UTF8, no preceeding will be added automatically, well enough.
system
|
|
|
|
|
followait wrote: I choosed to use CP_ACP instead of CP_UTF8, no preceeding will be added automatically, well enough. [Smile]
The text editor is adding them, not Windows.
Steve
|
|
|
|
|
notepad.exe in windows xp sp3 will add the preceding if windows thinks there is needs (eg. contains UTF-8 encode characters).
system
|
|
|
|
|
I that a question? If so I believe the answer is yes.
Steve
|
|
|
|
|
Hi all,
for printing i taking help with this article.
http://www.codeproject.com/KB/printing/QPrint.aspx[^]
With the help of this article the printing is done,But there is no option of print preview.
I want to seen first privew then printing.
What can i do please help me for this.
Thank in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
I suggest you read Roger Allen's articles[^] - he's written lots about printing, and print previewing, and the complex code plumbing needed.
All you ever wanted to know about printing, and never dared ask...
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
I am a Chinese girl,study Programming presently.Last year,I graduated from university.Now I an a software engineer .My English is not very good,so I want to find a friend who can keep Email with me in English .Beacause I want to study English truely.
If you can help me,please write a letter to me.
My E-mail:yangjinna66@163.com
My MSN:halibobo-520@163.com
I am waiting for your letter! thank you!
//??????????? ,?????????????,??,??????,??????????????
|
|
|
|
|
This is not a grammar class and it seems you have read out queries in ENGLISH and !(read not) with C++ perspective. Look closely most of the questions are related to C++ however "THEY" (the programmars here) do use ENGLISH to convey their problems.
If your english is not good how come you wrote all those lines in your query.
halibobo wrote: My MSN:halibobo-520@163.com
Apart from COM(in your email id) there is nothing that resembles with C++/MFC/ATL in general
IMHO, you should try and look for some english tutorials and
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
modified on Thursday, July 10, 2008 3:42 AM
|
|
|
|
|
Thanks for your reply,From your talking, i have trust in the future,through I writing this reply spend much time.
"Apart from COM(in your email id) there is nothing that resembles with C++/MFC/ATL in general "
----I don't know others web I can write this message.
|
|
|
|
|
Hi all,
I got this problem
DWORD dwData, Type, Size, dwRet, BufferSize;
BufferSize = TOTALBYTES;
PPERF_DATA_BLOCK PerfData = (PPERF_DATA_BLOCK) malloc( BufferSize );
Size = BufferSize;
lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, MPPARAM, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,&Regentry);
if (lResult == ERROR_SUCCESS) {
dwRet = RMRegQueryValueEx(Regentry, _T(SERIALNO), NULL, &Type, (LPBYTE) &dwData, &Size);
if( dwRet == ERROR_SUCCESS )
{
MPSerialNo = dwData;
lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, MPSYSTEMKEY, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,&Regentry);
if (lResult == ERROR_SUCCESS) {
dwRet = RMRegQueryValueEx(Regentry, _T(MAJORVER), NULL, &Type, (LPBYTE) &dwData, &Size);
MPVerNo = dwData;
}
}
}
return;
My problem is that after the first RMRegQueryValueEx even if it is successful, dwData when passed its value to MPSerialNo which is an integer it crashes. MPSerialNo is first used here after declaration so therefore its value is some negative numbers then it becomes empty after the RMRegQueryValueEx.
Please advice
Thanks,
jayjay
|
|
|
|
|
Your code has some problems...the fifth parameter to RegQueryValueEx should be the buffer that receives the value, and the sixth parameter is an in/out parameter. This sixth parameter should contain the size of the fifth parameter on input.
In your first call, parameter 5 is &dwData, but the size is set to the size of your PerfData (TOTALBYTES). That is incorrect - dwData is only 4 bytes long.
In the second call, Size is now 4 (as set by the first call), which is the size of dwData (which you again passed as parameter 5). You can see this if you step through your code in the debugger.
I'm not sure why you malloc PerfData (in fact you should use "new" instead of "malloc"), but never use it - perhaps that should have been used in your second call? You also don't delete the PerfData before returning from the function, so you'll have a memory leak each time you call this function.
In any case, you should remember to reset your Size parameter each time before you call RegQueryValueEx.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Hi all,
I am new to this forum and generally any programming help forum for that matter.
I have a case where i want to maintain both C and C++ api library. So therefore i choose to make my C++ support a thin wrapper around the C code. However, i do not know what is the most effective way to achieve this without unnecessary memory and performance overhead. Below is an example case.
/*Begin Code Sample*/
/*Start time.h*/
struct Time
{
int seconds,
int nanoseconds
};
void timeAdd(struct Time* time, struct Time* delta);
void timeSub(struct Time* time, struct Time* delta);
/*End time.h*/
/*Start timer.h*/
struct Timer
{
struct Time time;
void (*callback)(struct Timer *timer);
};
void timerSetCallback(struct Timer *timer, void (*callback)(struct Timer *timer));
void timerStart(struct Timer *timer);
void timerStop(struct Timer *timer);
/*End timer.h*/
/*Start time.hxx*/
namespace C
{
#include "time.h"
}
class Time
{
public:
Time()
{
m_time.seconds = 0;
m_time.nanoseconds = 0;
};
~Time(){};
int seconds(){return m_time.seconds;}
int nanoseconds(){return m_time.nanoseconds;}
void setSeconds(int seconds){m_time.seconds = seconds};
void setNanoseconds(int nanoseconds){m_time.nanoseconds = nanoseconds};
void add(Time &time){C::timeAdd(&m_time, &time.m_time);};
void sub(Time &time){C::timeSub(&m_time, &time.m_time);};
protected:
C::Time m_time;
};
/*End time.hxx*/
/*Start timer.hxx*/
#include "timer.h"
class Timer : public Time
{
public:
Timer():Time(){m_timer.callback = &Timer::callback;};
~Timer(){C::timerStop(&m_timer);};
start(){m_timer.time = m_time; C::timerStart(&m_timer);};
stop(){C::timerStop(&m_timer);};
protected:
static void callback(struct Timer *timer);
C::Timer m_timer;
};
/*End Code Sample*/
Now while this works for this simple case, it has a few drawbacks like the additional memory used to allocate m_time in class Time when all of struct Time api's would have even worked for struct Timer and hence struct Time m_time could have been "replaced" by struct Timer m_time but instead both exist in class Timer.
It also is the simpler of the cases where the struct sizes are relatively small and the call to Timer::start() was easily managed by a copy of the struct.
So now, my question is how can c++ wrappers be written for such cases without the additional memory overhead? Given their similarity, I definitely want class Timer to be a subclass of class Time!
However, i do have the flexibility to modify both the C and C++ code but i need both the C and C++ code to be equally capable, clean and efficient. How can i do it?
|
|
|
|
|
In case you don't know in C++ struct and class is basically the same thing. There is only one difference - in struct the default access is public while in class default access in private. So you can write code like this.
struct Time
{
int seconds,
int nanoseconds
};
void timeAdd(struct Time* time, struct Time* delta);
void timeSub(struct Time* time, struct Time* delta);
class CTime : protected Time
{
CTime()
{
seconds = 0;
nanoseconds = 0;
}
};
Hope this helps.
-Saurabh
|
|
|
|
|
Yes. I am aware of that. So that is easy when i have to create class Time but then what do i do with class Timer?
Cheers!
Kishore
|
|
|
|
|
With the code you provided I don't think you cannot wrap Timer in C++. Can you share how about about how timer callback is used?
-Saurabh
|
|
|
|
|