|
No problem.
I would recommend perhaps starting with a wizard-generated Win32 project. Even if it's just
a console app at least it will have all the basic headers set up for you and we can work from
there.
Mark
|
|
|
|
|
Do you mean open a new project with Win32 Appliaction (or Win32 Console Application)? However, I did open both of them ... I saw only a header stdafx.h!
|
|
|
|
|
Right. That stdafx.h, which is used as a precompiled header by default, combined with the
default preprocessor defines in the project settings, have all the basics you need.
You could copy those to your project if you need to and add the winsock2.h include to the
stdafx.h file (at the bottom should be fine).
Whatever it takes...the code should at least compile
Mark
|
|
|
|
|
You are absolute right, it now compile without any undeclared identifines
Many thanks, especially you are very patient!
|
|
|
|
|
Hi,
I am experiencing some real trouble with a simple windows program that I am trying to create. After running the CreateDialog() function, windows returns the error "Windows class not created". I am having trouble determing what this message is really telling me.
The result of this error message is that after processing the WM_SETFONT message inside the DlgProc for the Dialog Box that it creates, Windows always processes the WM_DESTROY instead of the WM_INITDIALOG which is the next message that my other working windows programs processes which creates and displays the dialog box. I have posted my WinAPI function below:
<br />
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine,<br />
int nCmdShow)<br />
{<br />
MSG msg;<br />
HWND mainWnd;<br />
<br />
<br />
hInst = hInstance;
InitCommonControls();<br />
<br />
<br />
mainWnd = CreateWindow("", "", 0, 0, 0, 0, 0, NULL,(HMENU)-1, hInstance, 0);<br />
<br />
MainDlgBox = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_AURACONNECT), mainWnd, (DLGPROC)DlgProc);<br />
<br />
DWORD Err = GetLastError();<br />
<br />
SetClassLong(mainWnd,GCL_HICON,IDI_EXE); <br />
<br />
<br />
while(GetMessage(&msg, NULL, 0, 0)) <br />
{<br />
TranslateMessage(&msg);<br />
DispatchMessage(&msg);<br />
}<br />
return msg.wParam;<br />
}<br />
Thank you for anyone who can offer any help.
Joe
|
|
|
|
|
Can you post your DlgProc code?
Also, if the dialog is the main window of the app, does it need the dummy parent window?
Mark
|
|
|
|
|
My DlgProc is rather lengthy, so I don't think I can post it, but is that what is most likely causing error? I don't know if it needs a dummy window, I'll try it without it.
|
|
|
|
|
TheDelChop wrote: but is that what is most likely causing error?
Actually I thought that might be the case, since you stated you had other similar working apps.
Looking at your code again this morning, though, I would try changng this line:
SetClassLong(mainWnd,GCL_HICON,IDI_EXE);
to
SetClassLong(mainWnd,GCL_HICON,LoadIcon(hInstance, MAKEINTRESOURCE(IDI_EXE));
|
|
|
|
|
Hello,
If I want to open a new document through the document view architecture but not through the File New option .Is there any way out.
How can I add a message handler to an object-ID so that it enables me to open a new document and then pass parameters to CDocument.
Prithaa
|
|
|
|
|
Hi guys -
I have a question about using Windows API Create():
I use this API to create a file by using parameter FILE_FLAG_DELETE_ON_CLOSE, since I want it automatically been deleted when it is been closed, the codes like below:
HANDLE handle = ::CreateFile(
_T("d:\\test.txt"),
GENERIC_WRITE,
FILE_SHARE_DELETE | FILE_SHARE_READ,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE,
NULL);
After I create the file I will write some information into it, of course. And the file will get deleted when it is closed -- so far so good.
In another process I will need to open this file to get the information I wroted in. I also uses CreateFile() to test if the file exists. However I always got a access violation when accessing to the file. A simple test case will be open d:\test.txt using notepad, it will tell you that the file is opened by another process. GetLastError always return a error 32 afterwise.
Here is what I see from MSDN:
>>>
FILE_FLAG_DELETE_ON_CLOSE
The system deletes a file immediately after all of its handles are closed, which includes the specified handle and any other open or duplicated handles.
If there are existing open handles to a file, the call fails unless they were all opened with the FILE_SHARE_DELETE share mode.
Subsequent open requests for the file fail, unless the FILE_SHARE_DELETE share mode is specified.
<<<
You can find from the code listed above, I *DO* have FILE_SHARE_DELETE specified. Why I still can not the file opened in another process?
Any suggestion or comments are greatly appreciated!
Cheers,
Jay
-- modified at 11:09 Thursday 30th November, 2006
|
|
|
|
|
Findekano wrote: In another process I will need to open this file to get the information I wroted in.
Can you post the code for CreateFile() in the process that reads from the file?
Mark
|
|
|
|
|
It is just an ordinary call..nothing special:
HANDLE hHandle = CreateFile(strFile,
GENERIC_READ,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
Jay Zhu@Shanghai, China
|
|
|
|
|
First off, you didn't allow shared write access when opening the original file.
Try using FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE for the share mode on both CreateFile()
calls.
|
|
|
|
|
It works! Thanks man!
Jay Zhu@Shanghai, China
|
|
|
|
|
Hi everyone.
Here is how I use CStatusBarCtrl in my dialog:
In OnInitDialog()
m_StatusBarCtrl.Create(WS_CHILD|WS_VISIBLE|CCS_BOTTOM|SBARS_SIZEGRIP,<br />
CRect(0,0,0,0), this, IDC_STATUS_BAR);<br />
<br />
int widths[1] = {-1};<br />
<br />
m_StatusBarCtrl.SetParts(1, widths);<br />
In OnSize()
<br />
m_StatusBarCtrl.SendMessage( WM_SIZE, 0, 0 );<br />
And when I need to update status, I invoke:
<br />
void CMyDlg::UpdateStatusBar(const std::string& in_rsNewStatus)<br />
{<br />
m_StatusBarCtrl.SetText(in_rsNewStatus.c_str(), 0, 0);<br />
<br />
}
But if the string is long enough, it is cut even when current StatusBar's size is able to encapsulate it! What is strange, is that it is cut differently: I mean, that number of letters, that are shown and the length of shown string in pixels are not equal for different strings.
Has anybody come across the same?
|
|
|
|
|
Are you sure you need to forward WM_SIZE messages to a CStatusBar control?
Have you tried NOT sending WM_SIZE to the control?
Mark
|
|
|
|
|
According to the documentation for SB_SETTEXT on msdn, "The text for each part is limited to 127 characters."
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
I am working with an equipment that only can be configuration through local Network! It use SNMP protocol (with UDP for parsing data). Anyone knows how to work with it?
Note: I did try the ServerSocket_Demo in this site, but it not the same. Because it only try to send information in TCP (or UDP) ... but not in SNMP. The result is: The equipment rejected both ways
Thanks to any help
|
|
|
|
|
|
I have learned about it, but the problem for me now is: Even I understand smome thing about it:
. Packet Info: (ie: packet length ...)
. Ethernet - II (ie: IPv4)
. IP (ie: version, source, destination, protocol ... checksum)
. UDP (ie: source, destination, protocol ... checksum)
. Extra data (...)
. FCS (...)
I still does not know how to imply in my VC++ program in order to link correctly with the equipment (Send/Receive SNMP packets)
Can you help?
|
|
|
|
|
I have never used the protocol but since it works over tcp/ip I would imagine you can send/recv
SNMP packets using sockets.
Do you need to know how to use sockets from C++?
Mark
|
|
|
|
|
In VC++ ... yes, if it can send SNMP packets as I described
Thanks
|
|
|
|
|
It looks like you have some studying to do...
Windows Sockets 2[^]
Maybe look around MSDN or Google and see if there's higher-level APIs or libraries for working
with SNMP. EVerything you need to know is documented somewhere
|
|
|
|
|
Hi Mark,
Thanks for the usefull links. I will work on it immediately
|
|
|
|
|
Ive been using Sleep() alot, but now i need something with smaller units, like microseconds or something. Ive used while loops that count a couble hundred, but there must be some more cpu friendly way to sleep a few microseconds?
any ideas?
maybe i could use timer? does it go down to that unit? if so how would i use that?
thanks
/Johannes
/Johannes
|
|
|
|
|