|
Giorgi Dalakishvili wrote: After posting this I found GetWindowModuleFileName Function
Looks easier than my method!
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Giorgi Dalakishvili wrote: but I will have to convert that to c# first
The System.Diagnostics namespace has the Process and ProcessModule classes but I don't see
a process-from-window method...
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark Salsbery wrote: The System.Diagnostics namespace has the Process and ProcessModule classes
Yes I'm aware about them but I will have only hwnd and I don't think I'll be able to solve the problem without winapi
|
|
|
|
|
Cool. Thanks for pointing out the GetWindowModuleFileName() API!
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I have an application which needs to upgrade firmwares of home routers automatically. I sniffed the outside packets when I click "upgrade" button and put everything I got in the code and do an HTTP Post function(not API. It works for other senario.). But it does not work. My question is why it does not work and how to make it work. Is it because HTTP protocol does not allow file upload like this? I have to have a web browser or email application to assist the file uploading?? Please advise me.
My code looks like this:
virtual int UpgradeFirmware(CString firmwareImage, CString RouterIP, CString Username, CString Password)
{
CString url = "http://" + RouterIP + "/upgrade.cgi";
CString ref = "http://" + RouterIP + "/Upgrade.htm";
CString request = "-----------------------------7d71f91e504ea";
request += "\nContent-Disposition: form-data; name=\"UpgradeFile\";";
request += " filename=\"C:\\firmware\\Netgear WGR614 V2\\wgr614v3_v2_16rc4.chk\"";
request += "\nContent-Type: application/octet-stream";
request += "\n-----------------------------7d71f91e504ea--";
CString page = HTTPPost(url, request, Username, Password, ref);
if(page.Find("Settings are successful.")>0)
return 0;
}
capulett
|
|
|
|
|
capulett wrote: CString page = HTTPPost(url, request, Username, Password, ref);
At this point, are url , request , and ref exactly how you expect them to be (e.g., commas, dashes, spaces, slashes)?
Does HTTPPost() return any sort of fail/success indicator?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for replying.
Yes, the url, request, and ref are exactly how I expect them to be. In my application, I use url, ref, request, and HTTPPost() very often to do some other operations. Only the updatefirmware operation fails. I suspect it has something to do with the file uploading. But I don't have any experience of it.
From the network sniffer, there is some mess following:
Content-Type: application/octet-stream.
It's the file which is uploaded. But I cannot put it in my code and it won't be right to put the messy stuff in the code. Do I need a way to uplode the file other than HTTPPost()?
Usually the HTTPPost() returns nothing. But it should return something indicates the upgrade is in progress...
I really don't know how to solve this. I will appreciate your help. Thanks a lot.
|
|
|
|
|
Dear Sir,
This Class help me very much.
But I want now to have a personal header(Name of society, date and so on) on my Excell Sheet.
How can I do So that my hearder line of fields begin in the 5th line for example.
I learn My self
|
|
|
|
|
Did you consider asking your question here?
mikobi wrote: But I want now to have a personal header(Name of society, date and so on) on my Excell Sheet.
So can't you just assign values to those cells?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
How do I get to know read individual lines from a multiline edit control?
Let me know the chunk of code. I do know of windows API to achieve the same.
|
|
|
|
|
tom groezer wrote: llinelength = ::SendMessage(hwnd, (UINT) EM_GETLINE, index, (LPARAM)(LPCTSTR)buffer);
What is index ?
tom groezer wrote: Now I have to use the a call to SendMessage with EM_GETLINE. How do I do that?
What exactly is your question: how to use the return value of EM_GETLINECOUNT , or how to send the EM_GETLINE message?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
This is the way i have implemented to read the lines from edit control.
LRESULT l_numEvents = ::SendMessage(hwnd, (UINT)EM_GETLINECOUNT, 0, 0);
LRESULT llinelength = ::SendMessage(hwnd, (UINT)EM_LINELENGTH, index, 0); index = 0 for first item
llinelength = ::SendMessage(hwnd, (UINT)EM_GETLINE, index, (LPARAM)(LPCTSTR)tbuffer);
I'm not able to execute the last staement properly.
MSDN says that the last parameter is "A pointer to the buffer that receives a copy of the line. Before sending the message, set the first word of this buffer to the size, in TCHARs, of the buffer. For ANSI text, this is the number of bytes; for Unicode text, this is the number of characters. The size in the first word is overwritten by the copied line.
How do I achieve what is mentioned in italisized code.
|
|
|
|
|
Wouldn't it make more sense to just send the control a WM_GETTEXT message? You can then parse the buffer (as individual lines) as necessary.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
How do I parse independent lines? is it something ot do with \r\n
|
|
|
|
|
It could be \r or \n or a combination of both.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Actually I wish to read one line at a time, do some processing and save it to the file. A multileine CEdit control do provide the logic to read one line at a time.
|
|
|
|
|
tom groezer wrote: A multileine CEdit...
You're using MFC? Why in the world would you be bothering with sending messages then? If you really want to get one line at a time from the control, see CEdit::GetLine() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I've used a customised list control that does alternate row shading but am also reading an article on how to get red text programmatically. As I'd like this too, I have added the necessary handling of NM_CUSTOMDRAW etc (well, I've found it in the shaded row source file),
what I want to do now is
if(some member variable in my single dialog)
then write this line in red
otherwise
write it in black
since I am in the function
void CColoredListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
what I want to know is how I can "get at" the parent dialog itself that has this listcontrol within it
something like
<getatthe cmaindialog="">.accessvariable
maybe
CWnd *GetParent(); is the first part, but then how do you get at the member variable (integer array that's within the parent dialog
I then thought of something like
CTestFolderBrowseDlg* myDlg = (CTestFolderBrowseDlg*)mainDlg;
and then using mainDlg as normal, but I can't include the header for my main dialog in this source file without it complaining, so I think I'm not doing this in the proper manner
for example if I put
#include "TestFolderBrowseDlg.h"
into ColoredListCtrl.cpp
it starts complaining about
testfolderbrowsedlg.h(33) : error C2065: 'IDD_TESTFOLDERBROWSE_DIALOG' : undeclared identifier
testfolderbrowsedlg.h(33) : error C2057: expected constant expression
which aren't present without the include to TestFolderBrowseDlg, but then the cast to myDlg from CWnd doesn't work
-- modified at 12:16 Monday 11th June, 2007
|
|
|
|
|
OK, this is what I am now trying in the function from the alternate shaded list view
void CColoredListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
...
////////////
LVITEM lvi;
memset(&lvi, 0, sizeof(lvi));
lvi.mask = LVIF_TEXT;
lvi.state = 0;
lvi.stateMask = 0;
unsigned char LVtext[16];
lvi.cchTextMax = 15;
// Length of string to be copied into pszText member
lvi.pszText = (LPTSTR)LVtext;
// String buffer for pszText member
// Nota bene : starts at zero (item) and ends at 'lCols' (last subitem) :
lvi.iSubItem = 5; // 6 columns in total, I assume that means 5 is the last one, also tried 4
// Retrieve the text in an item or a subitem of line 'i' :
mainDlg->SendMessage(LVM_GETITEMTEXT, (WPARAM) 0, (LPARAM) &lvi);
CString resultText(LVtext);
if(!strcmp((LPCSTR)LVtext, "Failed"))
{
do stuff...
}
///////////
it's never going into the do stuff bit. "Failed" is definitely being written/drawn in the listview report in the last column as per a SetItem call.
It would be easier if I could work out how to just get at data belonging to the dialog class itself that holds the listview control, but failing that, am not sure what I am doing wrong here.
|
|
|
|
|
ldsdbomber wrote: mainDlg->SendMessage(LVM_GETITEMTEXT, (WPARAM) 0, (LPARAM) &lvi);
The wParam should be the index of the item - are you always looking at item 0?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
no, I tried passing iRow first and that didn't work either (iRow presumably is the right parameter)
void CColoredListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
*pResult = 0;
LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)pNMHDR;
int iRow = lplvcd->nmcd.dwItemSpec;
switch(lplvcd->nmcd.dwDrawStage)
{
case CDDS_PREPAINT :
{
*pResult = CDRF_NOTIFYITEMDRAW;
return;
}
// Modify item text and or background
case CDDS_ITEMPREPAINT:
{
// ACCESS errTable here, and change font accordingly
CWnd* mainDlg = GetParent();
// CTestFolderBrowseDlg* myDlg = (CTestFolderBrowseDlg*)mainDlg;
////////////
LVITEM lvi;
memset(&lvi, 0, sizeof(lvi));
lvi.mask = LVIF_TEXT;
lvi.state = 0;
lvi.stateMask = 0;
unsigned char LVtext[16];
lvi.cchTextMax = 15;
// Length of string to be copied into pszText member
lvi.pszText = (LPTSTR)LVtext;
// String buffer for pszText member
// Nota bene : starts at zero (item) and ends at 'lCols' (last subitem) :
lvi.iSubItem = 5;
// Retrieve the text in an item or a subitem of line 'i' :
mainDlg->SendMessage(LVM_GETITEMTEXT, (WPARAM) iRow, (LPARAM) &lvi);
CString resultText(LVtext);
if(!strcmp((LPCSTR)LVtext, "Failed"))
{
do something here...
}
///////////
lplvcd->clrText = RGB(0,0,0);
// If you want the sub items the same as the item,
// set *pResult to CDRF_NEWFONT
*pResult = CDRF_NOTIFYSUBITEMDRAW;
return;
}
// Modify sub item text and/or background
case CDDS_SUBITEM | CDDS_PREPAINT | CDDS_ITEM:
{
if(iRow %2){
lplvcd->clrTextBk = m_colRow2;
}
else{
lplvcd->clrTextBk = m_colRow1;
}
*pResult = CDRF_DODEFAULT;
return;
}
}
}
|
|
|
|
|
>>lvi.iSubItem = 5; // 6 columns in total, I assume that means 5 is the last one, also tried 4
Also. subitems are 1 based. If you have 6 columns, subitem 6 is the last column.
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi,
I am making one application in VC++.NET. I want to pass one integer parameter to one thread function. How can I pass parameter to thread functions? My code is as below.
Thread function
public class TestThread
{
public:
static void ThreadProc()
{
...
}
};
Thread function call
Thread* myThread = new Thread(new ThreadStart(&TestThread::ThreadProc));
myThread->Start();
I want to pass one integer parameter in ThreadProc() .
Thanks in Advance
Priyank Raval
|
|
|
|
|
a global variable could to the job. Or has the ThreatStart-class overloaded constructors?
Greetings from Germany
|
|
|
|
|
Global variable?? NO! This is C++! Derive a class from Thread and you can make whatever
constructor and add whatever member variables you want
*EDIT ack it's sealed
Mark
-- modified at 13:05 Monday 11th June, 2007
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|