|
ldsdbomber wrote: I want to know the proper way to write data to this file
Well, you should know, your're designing the application and the file structure. Right?
Seriously, what do you mean by "proper"?
Just to be sure:
The CFileDialog class is simply for getting a filename and a path to a file that you either wants to read or write. The CFileDialog class does not perform any read or write operations on the file selected by the user. The OFN_OVERWRITEPROMPT flag only instructs the CFileDialog to warn the user if you opened a "SaveAs" dialog and the user selected an existing file. It has nothing to do with how the file is opened later.
BTW, you need an extra '|' at the end of your filter string.
--
Roger
It's supposed to be hard, otherwise anybody could do it!
|
|
|
|
|
Hi All,
I have created a window using the Win32 api functions. Now I created a message loop inside a member function of the class like so:
{<br />
UINT uMsg = 0;<br />
<br />
while (true)<br />
{<br />
if (::PeekMessage ((LPMSG) (&uMsg), m_hWnd, 0, 0, PM_REMOVE))<br />
{<br />
::TranslateMessage((LPMSG) (&uMsg));<br />
::DispatchMessage((LPMSG) (&uMsg));<br />
}<br />
else<br />
{<br />
if (MessageQueueEmpty () == FAILURE)<br />
{<br />
return FAILURE;<br />
}<br />
}<br />
}<br />
<br />
return SUCCESS;<br />
}<br />
However after the first iteration, this becomes NULL . If I make uMsg static, it works fine.
Why??
regards,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proof programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
-- modified at 10:24 Thursday 2nd March, 2006
|
|
|
|
|
This code has a few problems. Here’s is an edited down version of your code which shows the biggest:
UINT uMsg = 0;
::PeekMessage((LPMSG)(&uMsg), m_hWnd, 0, 0, PM_REMOVE)
The first parameter to PeekMesage is a LPMSG but your variable is of type UINT . You would get a compiler error if you tried the following code:
::PeekMessage(&uMsg, m_hWnd, 0, 0, PM_REMOVE)
You "solve" this by adding the following C-style cast:
(LPMSG)
This will never work, all you've done with this cast is say to the compiler, "Yeah I know a LPMSG isn't the same as a UINT* and you normally wouldn't compile this code but I'm the man, just blindly push ahead and compile it anyway". The problem is a UINT isn't a MSG , cast or no cast.
Here's what it should look like (edited down version):
MSG m;
::PeekMessage(&m, m_hWnd, 0, 0, PM_REMOVE)
A word of advice:
Never use C-style casts (a type in brackets). Always use function style casts instead. When you find yourself tempted to write (UINT)i write static_cast<UINT>(i) instead. If the cast doesn't make sense the compiler will complain (you can still get into trouble but the chances are a lot less). If you want to make the compiler do what you say as a C-style cast does use a reinterpret_cast . Casts are ugly (but occasionally necessary) and generally indicate a design flaw. The function style casts syntax allows you to spot casts more easily. Also C-style casts are not fine grained enough where as function style casts come in four types: dynamic_cast , static_cast , reinterpret_cast , const_cast so it is clearer and harder to abuse.
Steve
|
|
|
|
|
Hi Steve,
Thanks for the answer. Very helpful even though I can't believe I didn't see it.
thanks again,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proof programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
Hi,
I am using a richedit as a chat buffer.
When a new chat message is received, I use this:
chat_window_rich.SetSel(GetWindowTextLength(chat_window_rich), -1);
chat_window_rich.SetSelectionCharFormat(cf);
chat_window_rich.ReplaceSel(buff);
Where buff is the new text, and cf is the color and formatting of the new text.
However, for some reason, sometimes if a person has text highlighted and a message is received, some or all of the highlighted text will just delete. I have no idea what could be causing it.
I also have a check to see if the user is scrolled up, in which case I turn off redraw and manually set the scroll position back to where it should be. Could this also be part of the problem? People say that they see the problem more often when they are scrolled up.
Thanks!
Kelly Ryan
|
|
|
|
|
Hi,
I am writing a prog that needs to store info on a specific USB dongle.
In order to do that, I need the drive letter of the dongle.
I have the vendor ID & the product ID of the dongle...
Thanks!
|
|
|
|
|
Does anyone know "offhand" how I can intercept when the user clicks on a Tab (Tabcontrol) on a propertysheet (that is not in wizard mode,) or uses the keyboard to navigate between property pages on a property sheet. I would like (under certain circumstances) to disable the user from changing between property pages on the property sheet, but stll be able to do this programatically. Thanks in advance
Phil
bum... and I thought I´d got rid of all the bugs
|
|
|
|
|
Oh well... solved the problem myself in the end... here is what I came up with incase anyone has a similar situation.
Override the PreTranslateMessage function in your CPropertySheet derived class...
BOOL CmyDerivedClass::PreTranslateMessage(MSG* px_msg){
if(m_bStopUserClickingonTabs &&
(px_msg->message == WM_LBUTTONDOWN || px_msg->message == WM_LBUTTONUP))
{
// Get the Tabl Control
// ********************
CTabCtrl* pTabCtrl = GetTabControl();
ASSERT(NULL != pTabCtrl && ::IsWindow(pTabCtrl->m_hWnd));
if(NULL != pTabCtrl && ::IsWindow(pTabCtrl->m_hWnd)){
CRect rect;
pTabCtrl->GetClientRect(&rect);
if(rect.PtInRect(px_msg->pt)){
return TRUE;
}
}
}
// Call the base class
// *******************
return CPropertySheet::PreTranslateMessage(px_msg);
}
This will not of course stop the user using the keybaord to switch between property pages, but this is sufficiant for my needs. If anyone has a more "elegant" method, then please, drop a line...
mfg
Phil
bum... and I thought I´d got rid of all the bugs
|
|
|
|
|
Does it still use microsoft dll ??
|
|
|
|
|
if you are talking about MFC, then the answer is no. But you can develop core win api applications with it.
if you are looking for a good toolkit, try QT from trolltech. it is free for developing non-commercial applications and it supports mingw as a compiler. if you are not lucky with QT, you can hava a look at wxwindows.
hope that helps you out.
walter
|
|
|
|
|
hello I have a problem using mapi.
I want to send mail using the mapi functions
I use MapiLogon(NULL,NULL,NULL, MAPI_NEW_SESSION, 0, &sessionHandle); like this
then I get ready the Mesaje Mapi Structure then I use
MapiSend(0,0,Message,0,0)
and I get an error with don't send bla bla bla.
Can some one tell me what steps am I missing ?
gabby
|
|
|
|
|
euacela wrote: and I get an error with don't send bla bla bla.
Can some one tell me what steps am I missing ?
Not without knowing what the exact error is, and what statement is causing it.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
euacela wrote: hello I have a problem using mapi.
Hain Eucela,
AFAI remember, you have said you not going come back for your problem on this site ...? what the transformation... do u remember my word last time... we are social animals we someway and otherway need guidence or help of other people.... hope you go my point this time
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
dude shut the f*** up;
i don't need you and people like you.
you know the answer to my questio ? wanna tell me ? tell me! otherwise I don't need you
gabby
|
|
|
|
|
euacela wrote: dude shut the f*** up;
calm down buddy..... ok i will not come in your way!
|
|
|
|
|
Hi,
Which is the last message processed by a normal WindowProc?
Is it WM_DESTROY ?
Thank you...
- NS -
|
|
|
|
|
I think WM_NCDESTROY is amongst the last.
Steve
|
|
|
|
|
Yes, as per my knowledge WM_DESTROY is the last message processed by WinProc function. Because after recieving this message it starts destoying the memory used by window, and released the window resources. And obviously, the message queue will be no longer exist after resource release, and the window no exists to receive any msg...
-Malli...!
|
|
|
|
|
|
Hello Friends !
I'm trying to build the recordset with custom fields those are not taken from any table. This i can do in VB as below
Public ResponseInfo As ADODB.Recordset
Set ResponseInfo = New ADODB.Recordset
ResponseInfo.CursorLocation = adUseClient
Do Until <somecondition_overhere>
ResponseInfo.Fields.Append "MsgFieldName",adVarChar,250
Loop
ResponseInfo.Open
ResponseInfo.AddNew
'some blaa blaa manipulation with ResponseInfo
This is working fine in vb. but what i implemented in VC++ (Using #import "msado15.dll")is not working. Because Open() doesn't take 0 parameters. so, is ther any other logic to build such dynamic recordset (recordset holding dynamic coulmns, those are not from tables). I wanna to add columns of recordset dynamicaly, that too the columns are note associated with any table (this is mendatory point).
Please get me some help...!
-Malli...!
|
|
|
|
|
guess it depends on what you're trying to do. if you actually want to add them to a table later, why not just use a 'CREATE TABLE' statement, execute it, then make a recordset based on that table. then populate it with whatever you want. Or make a dummy SELECT statement from a real table something like this:
select cast('' as varchar(250)) as MsgFieldName from realtable
I just tried this in query analyzer and it works. You could do that for all the field names so that if you actually have a connection, it won't matter which table you pick, just pick any. Add the other fields as appropriate.
My Music | My Pics | My Articles
BlackDice
|
|
|
|
|
Thanks BlackDice !
I was using the same logic before i.e. create table wala. Yours one is really nice code ! It worked fine ! one more problem i suffered is that, i couldn't update the rows of the recordset. I've put the code showing how I coded. Can you get me some help, to update the recordset (insert record or update values of fields).
sprintf(SqlTempQuery,"select cast('FieldValue' as varchar(20)) as testcolumns from tmptable");
pTemRec->Open(SqlTempQuery,_variant_t((IDispatch *) pConn, true),adOpenDynamic,adLockBatchOptimistic,adCmdText);
pTemRec->AddNew("testcolumn","10"); //this line gives runtime error//
Error Description what I got from catch block is : "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done."May I get more light on the issue... Get me some logic to get work done...!!!
-Malli...!
|
|
|
|
|
I have string of Hex values,so i should concatenate two hex values from the string and wanted to convert these Hex values to Binary format and after converting to binary, how should i mask the last three binary values?
|
|
|
|
|
srija wrote: the last three binary values
are you talking about bits, bytes, or something else ?
to convert from hexa representation to binary representation, it's easy. each hex character equals 4 bits :
CString strBinary;
switch (char cHex) {
case '0': strBinary = "0000"; break;
case '1': strBinary = "0001"; break;
case '2': strBinary = "0010"; break;
case '3': strBinary = "0011"; break;
case '4': strBinary = "0100"; break;
case '5': strBinary = "0101"; break;
case '6': strBinary = "0110"; break;
case '7': strBinary = "0111"; break;
case '8': strBinary = "1000"; break;
case '9': strBinary = "1001"; break;
case 'A': strBinary = "1010"; break;
case 'B': strBinary = "1011"; break;
case 'C': strBinary = "1100"; break;
case 'D': strBinary = "1101"; break;
case 'E': strBinary = "1110"; break;
case 'F': strBinary = "1111"; break;
}
|
|
|
|
|
I said about bits. I have array[6]={0x7D 0x0c 0x2f 0x65 0xA5 0x4B}...
I should convert all Hex bytes to Binary format and then i should concatenate.
for Eg:0001111111111111, now i should mask the last three bits i,e 000.
|
|
|
|
|