|
After I added the IProvideClassInfo interface to my objects. It can run now. However, for the script below, it runs correctly.
-------------------------------------
dim cnt
set cnt = Application.Documents
-------------------------------------
However, for the code below, it raised runtime error:
Object required: 'Application.Documents.Count'
-------------------------------------
dim cnt
set cnt = Application.Documents.Count
-------------------------------------
In Documents, I've already implemented a property Count for the enumeration.
STDMETHOD(get_Count)(LONG* pVal);
Anything wrong ?
|
|
|
|
|
dim myobj,cnt
set myobj = CreateObject("Application.Documents")
cnt = myobj.Count
STL is a religeon. Enquiries to Reverend Christian Graus
|
|
|
|
|
Hello,
I have various child control windows in my CDialogBar derived class and would like to make intializations to them after the DialogBar windows have been created. What message should I use? WM_INITDIALOG is not available to CDialogBar.
Thanks!
JennyP
|
|
|
|
|
Override the Create() method, and call the base class. If it returns successfully, do your initialization.
---
Shog9
If I could sleep forever, I could forget about everything...
|
|
|
|
|
How can i have a popup menu displayed when i right click on the empty space of menu bar?
|
|
|
|
|
You can check for right click on the menu bar by handling WM_NCRBUTTONDOWN (or related messages) in your mainframe class (provided you use MFC, else handle the message in the WndProc of your main window). the nHitTest parameter (or wParam if SDK) will contain the value HTMENU (=5). For more info, check out CWnd::OnNcRButtonDown or CWnd::OnNcHitTest in the docs.
The popup is displayed by using TrackPopupMenu.
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"
|
|
|
|
|
hi all,
i want to know when recv() function will return.
apart from the buff is full, i experience that it will return sometimes. but, i don't so sure when such situation will happen.
how can i control when the recv() return? or, is it in random manner?
try to give me some idea!
thanks,
jim
|
|
|
|
|
recv() function returns when it has received some data. We cannot predict how many bytes it returns. This depends on your network and the buffer and various other factors.
For example if the sender has sent a string "hello world", this might come in any of the following ways or even other ways.
1 single packet - "hello world" - recv() returns 11
2 packets - "he" and "llo world" - recv() returns 2 and 9
3 packets - "he", "llo w" and "orld" - recv() returns 2, 5 and 4
3 packets - "hello", " w" and "orld" - recv() returns 5, 2 and 4
What I am trying to put through is that you need to loop your recv() call till you are sure all the data has come, probably by using some kind of termination code. SMTP uses \r\n.\r\n for example.
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
thanks!
let me make my question clearer.
for example, i want to send several ip to client. so, i send command "iplist\n"
then, sending "3", "xxx.xxx.xxx.xxx\n", "yyy.yyy.yyy.yyy\n", "zzz.zzz.zzz.zzz\n".
so, are there any method to make sure i can receive 5 times from recv()?
my concern is that, if i can receive the command and data line by line. i can handle the data directly without saving the data to temp buffer.
any idea?
thanks,
jim
|
|
|
|
|
zecodela wrote:
so, are there any method to make sure i can receive 5 times from recv()?
Not really. You will have to parse what the recv() call gives you. Anyway you should always check the data returned and run some sanity checks. Never trust what the network sends.
If you really wanted to split up the recvs you could either use setsockopt(SO_RCVBUF) to set the size of the recieve buffer. Becareful here as it might screw up performance or else pass a small-sized buffer to recv. Frankly I don't see why you should want 5 recvs(): it's better to get it all in one big buffer.
HTH
Brian Azzopardi
bibamus, edamus, cras moriemur [eat, drink, for tomorrow we die]
|
|
|
|
|
Hi Jim ,
recv()basically is a blocking call. It blocks unless it gets some data on that socket. U don't want recv to block u use Asynchronous calls like WSAAsyncSocket() or CAsyncsocket class for creating ur socket. With u async socket u will get notification to receive or when data is still pending.
cheers,
|
|
|
|
|
Hi,
I have a number of txt files, such as, f01.txt, f02.txt, ....f38.txt.
Now i want to combine these files into one new file named such as f.txt.
In some extend, i known that how to find these files recursively and how to form the new files. But I'm not clear about how to copy the contents of the single text file into the new file without the lose of the style or format of the text contents?
Is there a method for copy all the contents of the f01.txt into the f.txt for one time?
Thanks in advance!
chen
chen
|
|
|
|
|
Basically this is what you need to do
- Open an output file in write mode
- Open the next input file in read mode
- Keep reading from input and writing to output
- Close input file
- Go back to step 2 if there are more input files
- Close output file
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Use GetFileSize to find the size of the f01.txt file in bytes.
Then use ReadFile with the lpNumberOfBytesRead parameter set to the value returned by GetFileSize.
Then use WriteFile with the nNumberOfBytesToWrite parameter set to the value returned by GetFileSize.
Jason Henderson quasi-homepage articles "Like it or not, I'm right!"
|
|
|
|
|
Thanks for the information.
|
|
|
|
|
Hi.
I design and implement Windows programs using MFC and its doc/view architecture. Currently I am studying Jeffrey Richter's Programming Applications for Microsoft Windows. It is an amazing booking with unparrelled insights to Windows core.
In his book, Richter demonstrates thread synchronization both at user-mode and at kernel object levels using Win32 API. For example, for critical sections, you can call EnterCriticalSection(...). For events, you can call CreateEvent(...).
Anyways, I have studies from Jeff Prosise's Programming Windows with MFC. Prosise demonstrates thread synchronization using MFC tools including CCriticalSection, CEvent, CMutex, as well as CSingleLock.
Again, I have no experience with Win32 API GUI tools. I would like to know is it what is the preferred tool for thread synchronization: Win32 API or MFC? Both techniques make use of the same thread synchronization tools. I want to know which technique is more powerful now and in the future.
I really enjoy working with Win32 API, just not for GUI.
Thanks,
Kuphryn
|
|
|
|
|
The MFC thread synchronization classes are essentially thin wrappers for the underlying Win32 synchronization objects. If your project uses MFC, then you'd save some time and effort if you use the MFC wrappers. On the other hand you mention that you enjoy pure API coding, from which I assume that you prefer native API coding to MFC. If that's the case you may use the API calls directly. For example instead of using the CCriticalSection class you'd have to use InitializeCriticalSection , EnterCriticalSection etc. Performance wise you won't find any difference.
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Nicely explained! Thanks.
Kuphryn
|
|
|
|
|
Can anyone provide the checksum algorithm for MS Access OLE Object fields? I am looking for the Paint bitmap trailer which consists of 12 bytes appended to the bitmap like this:
0x01 0x05 0x00 0x00
0x00 0x00 0x00 0x00
0xcb 0xad 0x05 0xfe
The last 4 bytes are the checksum. Among the half dozen or so bitmaps I've checked, only the 0xcb byte seems to vary but all 4 are probably calculated. Thanks,
Ed
|
|
|
|
|
I am creating a server and a client apliction for sending/receiving files trough a CAsyncSocket derived class.But it seems that the server can't send all the file data troght the socket... I can't figure out why... here it is the code for sending the file on the server side :
void send_File(const CString &name)
{
CFile f;
unsigned char buffer[512];
int n;
f.Open(name,CFile::modeRead|CFile::shareDenyNone);
while ( (n = f.Read(buffer,512)) )
if (!PacketSend(*ClientSocket,buffer,n))
AfxMessageBox("Error sending packet...");
f.Close();
}
//code of PacketSend function
bool CConversarDlg::PacketSend(CMySocket &sock,void *buffer,const int &length)
{
//the "head" of each packet is an int, which tells the client how many bytes the packet has (packet length)
int total = sizeof(int) + length;
int sent;
int bufpos = 0;
BYTE *buf = new BYTE[sizeof(int) + length];
memcpy(buf,&length,sizeof(int));
memcpy((void *) (buf+sizeof(int)),buffer,length);
do
{
sent = sock.Send(buf+bufpos,total);
if ( sent == SOCKET_ERROR ) return false;
total -= sent;
bufpos += sent;
if ( total > 0 ) Sleep(20);
} while ( total > 0 );
delete [] buf;
return true;
}
Well, I always got the messagebox saying "error sending packet..." when I call the function send_file(const CString &); But this only occurs when a file is larger then a 5 kbytes. I can't figure out why.I am a beginner with sockets and tcp/ip.... Anyone could help? Thanks.
|
|
|
|
|
Hello, the codegurus around the world.;)
Even though I can't point out something wrong of your code, your code may
work if you send only one file within 512 characters.
You check if the first send(...) function successfully sends the data.
If not, try not to call send function at all.
At the same time, you had better check if CFile reads the exact buffer before
Send function is called by thread and CEvnet.
(This means that Socket send function may be called before CFile object
restore the 512 bytes data to the buffer?)
You can check these codes in Guncleus project (P2P application)
Go to my article, and try to go to Guncleus project web site, and download
the free code. And Check GnuUpload.h and GnuUpload.cpp, and you will find some
code of how to upload the files.
Please, don't send me your email about your questions directly.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
I would like to send an ASCII string out my serial port by pressing one of the buttons. I don't need it to effect anything else just the one specific string. A friend gave me an idea how to do it. I was wondering if everyone could take a look at my code and tell me what I need to change to complete it. I hope this makes sense what I said. I am new to Visual C++
const char * AsciiCmd = "GO";
CreateFile(AsciiCmd, GENERIC_READ |GENERIC_WRITE,
0, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
WriteFile(AsciiCmd, GENERIC_READ //I don't know what to put in next or if this is even going to work.
thankyou for any help you can give.
Mavrock
|
|
|
|
|
I'm stumped and need help. Why does my modeless property sheet show up right from the get go?
I have my property sheet stuff in CMainFrame (MainFrm.cpp/.h). I have a CPropertySheet derived class, CMySheet, and do the following in MainFrm.cpp:
m_pMySheet = new CMySheet("My Modeless Form", this, 0);
m_pMySheet->Create(this, -1, NULL);
I created a modeless property sheet and have overridden the CPropertySheet::OnInitDialog() operation as follows:
BOOL CMySheet::OnInitDialog()
{
// Setting of m_bModeless to FALSE and then TRUE is a trick from CodeGuru
m_bModeless = FALSE;
BOOL bResult = CPropertySheet::OnInitDialog();
m_bModeless = TRUE;
// The rest of my sheet's initialization - fields, controls, etc...
return bResult;
}
As soon as I run my executable, up pops my modeless property sheet. I don't want this to happen until my controlling dialog (dialog, menu item/menu bar) displays the property sheet.
Thanks in advance.
Johnny
|
|
|
|
|
Ok, I think I found out by examining my m_pMySheet->Create() statement, Sorry for this original post.
Here is what I should have examined:
m_pMySheet->Create(this, -1, NULL)
with the second parameter -1, the Create() function employs the following style WS_VISIBLE | WS_SYSMENU | WS_POPUP | WS_CAPTION | DS_MODALFRAME
What I should do is explicitly define my window's (prop-sheet's) style to not have WS_VISIBLE.
See ya...
Johnny
|
|
|
|
|
My debug is constantly screwing up royally.. if i trace a section of code it will jump from one line to a few down and just skip stuff.. the locals window doesnt show anything but 'this' and everything under that is a value that cant be evaluated..
its like my debug is debugging code that is no longer there .. it will go over statements and just do what it wants to almost.. then five minutes later it will mystically work even though i didnt change the part i was trying to debug at all..
i have tried to clean solution and rebuild all, but this does nothing to fix this problem.. anyone seen this before? stupid .net is a little buggy i feel..
-dz
|
|
|
|
|