|
freehawk wrote:
n a message be posted to a dll from other dll?
No. You'll either need to call a function in the other DLL, or use some other form or IPC.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I’m trying to use Wininet to access web pages. If I use InternetOpenUrl, I can access a stock quote off of Yahoo. If I try and use an alternative involving HttpSendRequest, I get an “object not found” error. I have tried different ideas for the Open Request, but with no success....
What am I doing incorrectly?
// the code here in “OnButtonUrl” works
void CHttpAppDlg::OnButtonUrl()
{
HINTERNET hOpenHandle, hConnectHandle, hResourceHandle;
CHAR lpszBuffer[256];
DWORD dwRead, dwFlags, dwStatus;
CString strStatus;
CHttpRequestDlg dlg;
if (IDCANCEL == dlg.DoModal()) return;
m_strResult.Empty();
// Initialize WinInet and create the Internet session
hOpenHandle = InternetOpen("HttpApp/1.1", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (!hOpenHandle) return;
hResourceHandle = InternetOpenUrl(hOpenHandle, http://finance.yahoo.com/q?s=intc",NULL,0,0,0);
if (!hResourceHandle)
{
InternetCloseHandle(hOpenHandle);
return;
}
if (!QueryInfoStatusCode(hResourceHandle, dwStatus))
AfxMessageBox("Error in QueryInfoStatusCode");
else
{
if (HTTP_STATUS_OK != dwStatus)
{
CString strMsgFormat("HTTP Status Code: %d, Reason: %s"), strMsg;
if (!QueryInfoStatusText(hResourceHandle, strStatus))
strMsg = "Unknown";
strMsg.Format(strMsgFormat, dwStatus, strStatus);
AfxMessageBox(strMsg);
}
else
{
while (InternetReadFile(hResourceHandle, lpszBuffer, 255, &dwRead))
{
if (dwRead == 0)
break;
lpszBuffer[dwRead]=0;
m_strResult += lpszBuffer;
}
}
}
//cleanup
InternetCloseHandle(hResourceHandle);
InternetCloseHandle(hOpenHandle);
//update dialog
UpdateData(FALSE);
}
This code in “OnOK” does not work. It returns a error 404 “can’t find object”
void CHttpAppDlg::OnOK()
{
LPCTSTR lpszAcceptTypes[] = {"Accept: */*", NULL};
HINTERNET hOpenHandle, hConnectHandle, hResourceHandle;
DWORD dwError = ERROR_INTERNET_FORCE_RETRY, dwErrorCode;
CHAR lpszBuffer[256];
DWORD dwRead, dwFlags, dwStatus;
CString strStatus;
CHttpRequestDlg dlg;
BOOL result;
if (IDCANCEL == dlg.DoModal())
return;
m_strResult.Empty();
// Initialize WinInet and create the Internet session
hOpenHandle = InternetOpen("HttpApp/1.0", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (!hOpenHandle) return;
// check to see if the user wants to use SSL
dwFlags = (dlg.m_nPort == 443) ? INTERNET_FLAG_SECURE : 0;
// establish the connection with the HTTP server
hConnectHandle = InternetConnect(hOpenHandle, "www.yahoo.com",
80, NULL, NULL, INTERNET_SERVICE_HTTP,0,0);
if (!hConnectHandle)
{
InternetCloseHandle(hOpenHandle);
return;
}
// create the HTTP request
hResourceHandle = HttpOpenRequest(hConnectHandle,"GET","http://finance.yahoo.com/q?s=intc",
"HTTP/1.1", NULL,(LPCTSTR *) &lpszAcceptTypes,0, 0);
if (!hResourceHandle)
{
InternetCloseHandle(hConnectHandle);
InternetCloseHandle(hOpenHandle);
return;
}
// keep sending until authentication is successful
while ( ERROR_INTERNET_FORCE_RETRY == dwError)
{
result = HttpSendRequest(hResourceHandle, NULL, 0, NULL,0);
// dwErrorCode stores the error code associated with the call to HttpSendRequest.
dwErrorCode = result ? ERROR_SUCCESS : GetLastError();
dwError = InternetErrorDlg(GetSafeHwnd(), hResourceHandle, dwErrorCode, FLAGS_ERROR_UI_FILTER_FOR_ERRORS |
FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS |
FLAGS_ERROR_UI_FLAGS_GENERATE_DATA,
NULL);
}
if (!QueryInfoStatusCode(hResourceHandle, dwStatus))
AfxMessageBox("Error in QueryInfoStatusCode");
else
{
if (HTTP_STATUS_OK != dwStatus)
{
CString strMsgFormat("HTTP Status Code: %d, Reason: %s"), strMsg;
if (!QueryInfoStatusText(hResourceHandle, strStatus))
strMsg = "Unknown";
strMsg.Format(strMsgFormat, dwStatus, strStatus);
AfxMessageBox(strMsg);
}
else
{
while (InternetReadFile(hResourceHandle, lpszBuffer, 255, &dwRead))
{
if (dwRead == 0)
break;
lpszBuffer[dwRead]=0;
m_strResult += lpszBuffer;
}
}
}
//cleanup
InternetCloseHandle(hResourceHandle);
InternetCloseHandle(hConnectHandle);
InternetCloseHandle(hOpenHandle);
//update dialog
UpdateData(FALSE);
}
DanL
|
|
|
|
|
Try:
hConnectHandle = InternetConnect(hOpenHandle, <code>"finance.yahoo.com"</code>, 80, NULL, NULL, INTERNET_SERVICE_HTTP,0,0); and
hResourceHandle = HttpOpenRequest(hConnectHandle,"GET", <code>"/q?s=intc"</code>, "HTTP/1.1", NULL,(LPCTSTR*) &lpszAcceptTypes,0, 0);
rechi
|
|
|
|
|
Yes, it works. I was also able to do a "POST" which is what I was after in the first place.
Thanks so much for taking the time to read and answer my question.
DanL
|
|
|
|
|
Hi there,
I've read articles on how to create tooltips for buttons and other objects but nothing on just plain text. I would like to create tooltips for my submenu items on the IDR_Mainframe. How can I go about doing this?
Thanks!
|
|
|
|
|
|
hi, I just wanted to write a simple mp3 player, anyone can tell me wich libraries sould I use to play an mp3 file? can I use Windows Media Player's one without being forced to use media player GUI? thanks
Paolo
|
|
|
|
|
yes, you sure can. You need the Direct X SDK.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I'm currently in the process of adding Unicode support to a website that acts as a file repository. Users are able to upload/download files to this site via http or webdav. Currently, if a user uploads a directory to the site, we use a 3rd party activex component from Software Artisans that creates a zip file archive of the folder on the client workstation, then uploads, and unzips the archive on the server side. I'm currently adding unicode support for our Japanese, Korean, Chinese, etc users. I've discovered that the zip archive component that we use, has very weak support for unicode filenames & foldernames. It appears that it's not unicode aware, but relies on code page conversions. If both the user workstation and the server are running the same default codepage, the zip archive process works fine. If the two are not the same, the files are corrupted upon unzipping.
Looking around, from what I can tell, WinRar is the only archiver that appears to be unicode aware. Unfortunately, there don't appear to be any 3rd party activex components that are capable of creating a rar file. And Rar Labs doesn't appear to have a developer sdk.
Does anyone have any ideas, or know of any examples I can look at regarding adding support for creating unicode aware file archives? Are there any other file archive formats that are unicode aware besides rar? Is tar capable of archiving unicode filenames?
|
|
|
|
|
try the 7-zip
it is open source and suprise, it support rar format.
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
Thank you, thank you, thank you! This is exactly what I'm looking for, and initial testing shows that it does support unicode. I should have come here looking for tips much sooner!
|
|
|
|
|
All,
I am trying to use the Picture Control tool from the toolbox to add a picture to my main display window. The picture would be a small box located to the right of text string. When I create the picture control, there is an "Image" field whose description reads as follows:
Image: When Type is Icon or Bitmap, specifies the identifier of the image to use
So, I set the Type filed to either Icon or Bitmap. But, I am unable to enter a file location of the image that I would like to load. When I enter the string C:\Red Button.bmp into the Image field it comes back with the error:
The identifier contains illegal characters
The bigger picture here is that I have a list of voltages and temperatures being displayed numerically. Next to each one I would like to display either a green, yellow, or red small rectangle to indicate whether the engineering readings are ok or need some type of action. I thought I could just use the picture control to put up pictures of solid colored rectangles, and that the code might be able to change these on the fly somehow.
Robert
|
|
|
|
|
why don't you just draw a rectangle and specify the color of the solid brush depending on what the reading is?
If it's broken, I probably did it
bdiamond
|
|
|
|
|
I'm working in Visual C++ (non-MFC). All the information in the help structure seems to show Visual Basic examples. Can you point me to a help topic that would show me how to do what you are suggesting? Yes, if I can call a routine that draws a rectangle of a certain size and color on my main display, that is all that I need to do.
Robert
|
|
|
|
|
I just posted an answer using MFC, but these functions are just wrappers for the api's that you should be able to get with C++. I don't know the exact syntax, but it shouldn't be too dissimilar. Sorry I don't know more
If it's broken, I probably did it
bdiamond
|
|
|
|
|
here's some sample code also. I just put this in my OnButton1() function just to demonstrate. but here's a red rectangle being drawn. Of course you would have to put this in your paint event or something like that.
CClientDC dc(this);
CBrush b( RGB(255, 0, 0));
CBrush* pOldBrush = dc.SelectObject(&b);
dc.Rectangle(100,100,110,110);
dc.SelectObject(pOldBrush);
If it's broken, I probably did it
bdiamond
|
|
|
|
|
How to make a non-resizeable window?
|
|
|
|
|
if it's a dialog you should be able to set the appropriate border style property. Or if not, try handling the WM_SIZE (or WM_RESIZE) message so that it calls a this->Move(0,0,100,100) or whatever your original size is, or try handling it so that it does nothing.
If it's broken, I probably did it
bdiamond
|
|
|
|
|
It is SDI application with CFormView. I want to prevent resizing the main window. I tried handling WM_SIZE in CMainFrame and CFormView to do nothing, but it didn't work out. If I put MoveWindow() then the window starts resizeing but when you release a mouse button it goes back. But this solution is not what I wanted.
Is there a parameter that you can pass to Create() so it makes window non-resizeable, or some similar solution?
|
|
|
|
|
Depends on what kind of window library you're using. (MFC? WTL? Raw Win32?)
If you're using the raw Win32 API, you simply set the appropriate window style when calling CreateWindow() or CreateWindowEx(). It's the WS_THICKFRAME style that adds the resizable border, so don't use it. Also don't use WS_TILEDWINDOW or WS_OVERLAPPEDWINDOW, as those styles include use WS_THICKFRAME.
Try (WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU) as your window style. It will probably be exactly what you want.
|
|
|
|
|
It is SDI application with CFormView. I want to prevent resizing the main window. I put parameters you told me for CMainFrame and it worked. Thanx.
|
|
|
|
|
Glad it worked for you.
|
|
|
|
|
Try handling the WM_SIZING message.
...Plug & Pray...
|
|
|
|
|
Hello all
I have a application that reads the message sent from the printer.
the printer sends the window message, like DOC_START.
I have to register the same message that the printer registered.
<br />
BlackIcePrintMessage = RegisterWindowMessage(szREGISTERMESSAGE);<br />
if (!BlackIcePrintMessage)<br />
{<br />
dwError = GetLastError();<br />
return 0;<br />
} <br />
but how to get/read the message sent from printer..
here the sample code, it works.. but i'm using MFC, dialog based application and the sample code is not for MFC.. the sample code uses WNDCLASS wc and then register with RegisterClass(&wc).
<br />
int PASCAL WinMain(HINSTANCE hinstCurrent, HINSTANCE hinstPrevious, LPSTR lpszCmdLine, int nCmdShow)<br />
{<br />
..<br />
..<br />
..<br />
WNDCLASS wc;<br />
<br />
<br />
wc.style = 0;<br />
wc.lpfnWndProc = TestWndProc;<br />
wc.cbClsExtra = 0;<br />
wc.cbWndExtra = 0;<br />
wc.hInstance = hInst;<br />
wc.hIcon = LoadIcon(hInst, TEXT("TestIcon"));<br />
wc.hCursor = LoadCursor(NULL, IDC_ARROW);<br />
wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);<br />
wc.lpszMenuName = TEXT("TESTMENU");<br />
wc.lpszClassName = szMyClass;<br />
<br />
if (!RegisterClass(&wc))<br />
return FALSE;<br />
HWND hwndMyWindow = CreateWindow(szMyClass, TEXT("Black Ice printer Driver Message Capture Sample"),<br />
WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, 0,<br />
CW_USEDEFAULT, 0, NULL, NULL,<br />
hInst, NULL );<br />
<br />
if ( !hwndMyWindow )<br />
return FALSE;<br />
<br />
ShowWindow (hwndMyWindow, SW_SHOW);<br />
<br />
while ( GetMessage(&msg, NULL, 0, 0 ) )<br />
{<br />
TranslateMessage(&msg);
DispatchMessage(&msg);
}<br />
return (int) msg.wParam;
how can i also register my window class? would it be a right thing to use CCmdTarget class?
Thank you
|
|
|
|
|
Look up ON_REGISTERED_MESSAGE in MSDN for example on how to handle registered messages.
Ignore the sample code for WinMail (that you posted) - you do not need it in MFC.
Get trial copy of comment generating tool CommentMakerPro, std::string and std::string containers viewer FeinEvaluatorPro and windows manager for Microsoft Visual Studio .NET FeinWindows at www.FeinSoftware.com
|
|
|
|
|