|
No problem
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
I have an application created with VS2005, consisting of some com-components created with VS2005. But one of the components is created by another department, so this component is still created with VS6. To find an error i have to debug from my application (VS2005) into this semi-external component(VS6). I have the symbols (.pdb) and the source files for the component and i succeed in stepping into the code of the component. But i can't watch any symbol. Has the PDB-format changed between this studio versions, are there any tricks to do the thing ?
|
|
|
|
|
Hi,
I want to change radio button while my program is running.
It start with normal radio button, but a want to change it while running so the text would be on the left side and the button on the right.
(It would look like radio button with "Left Text = true" when u click the button properties.)
I tried
CButton* button = GetDlgItem(IDC_RADIO1)
button->SetButtonStyle(BS_LEFTTEXT)
button->SetButtonStyle(BS_AUTORADIOBUTTON | BS_LEFTTEXT)
and few more but i failed.
Any idea ?
|
|
|
|
|
That isnt a good idea because it confuses a lot of users. Better rethink the design.
(if you really want to confuse the user, use 2 Buttons with one invisible and change the visibility)
Greetings from Germany
|
|
|
|
|
ido000 wrote: Any idea ?
Yes,
HWND hWndRadio = ::GetDlgItem(this->m_hWnd, IDC_RADIO1);
LONG lStyle = GetWindowLong(hWndRadio, GWL_STYLE);
lStyle |= BS_LEFTTEXT;
SetWindowLong(hWndRadio, GWL_STYLE, lStyle);
::InvalidateRect(hWndRadio, NULL, TRUE);
::UpdateWindow(hWndRadio);
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I want to use of your code freely?
|
|
|
|
|
char str[8];
cin >> str;
When run, if inputed string size more than eight byte, result run time error.
So, how to limit cin >> size or only get eight byte when inputed more than eight?
thanks!
|
|
|
|
|
allocate memory dynamically based on the size of the string
You can use a loop (upto 8) along with getch()/getchar() to get the user input
Some things seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
cin statement doesn't provide you with limited input support. since it wait for RETRUN/ENTER key for updating the input character in buffer supplied to it.!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
std::cin.get(str, sizeof(str), '\n');
or
std::cin >> std::setw(sizeof(str)) >>str;
|
|
|
|
|
hanlei0000000009 wrote: When run, if inputed string size more than eight byte, result run time error.
Were you expecting a different result? Why not use a string object instead?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi Experts,
How can I import .rtf or .doc file content into TextBox.
|
|
|
|
|
Could anybody give reply?
|
|
|
|
|
For import doc file use rich edit control instead of edit control.
|
|
|
|
|
If you were using a rich edit control instead, you could just stream the data in.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi,
How can i get the path of the file opened, if i know that window handle.Is there any API for this.
Thanks
|
|
|
|
|
revanth1985 wrote: if i know that window handle
you can't find the name of file if you have window/FILE handle.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
If you are asking how to get the filename of an executable by knowing a window handle then this is how you do it. This code will tell you the PID of the executable even if you pass a child handle such as a button handle.
#pragma comment(lib, "psapi")
DWORD dwPID = -1;
BOOL CALLBACK EnumChildWindowsProc(HWND hWnd, LPARAM lParam)
{
if(hWnd == (HWND)lParam)
{
GetWindowThreadProcessId(hWnd,&dwPID);
}
return TRUE;
}
BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam)
{
if(hWnd == (HWND)lParam)
{
GetWindowThreadProcessId(hWnd,&dwPID);
}
else
{
EnumChildWindows(hWnd,EnumChildWindowsProc,lParam);
}
return TRUE;
}
BOOL FindWindowProcessModule(HWND Hwnd, TCHAR *szName,size_t iMaxLen)
{
EnumWindows(EnumWindowsProc,(LPARAM)Hwnd);
if(-1 != dwPID)
{
HMODULE hModule = NULL;
DWORD dwNeeded = NULL;
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,FALSE,dwPID);
if (NULL != hProcess)
{
if(EnumProcessModules(hProcess,&hModule,sizeof(hModule),&dwNeeded))
{
GetModuleFileNameEx(hProcess,hModule,szName,iMaxLen);
}
else
{
GetProcessImageFileName(hProcess,szName,iMaxLen);
}
CloseHandle(hProcess);
}
}
return NULL != szName[0];
}
Here is how you would use it:
TCHAR szName[MAX_PATH] = {0};
HWND Hwnd = (HWND)::FindWindow(_T("SciCalc"),_T("Calculator"));
if(FindWindowProcessModule(Hwnd,szName,MAX_PATH))
{
MessageBox(szName);
}
else
{
MessageBox(_T("Calculator is not running."));
}
Best Wishes,
-David Delaune
|
|
|
|
|
Hi,
Thanks for your reply.I don't want the path of the executable file,i want the working station of that file(for ex: D:\Work\New Text Document.txt).
|
|
|
|
|
You want the name of the process which has the file opened?
|
|
|
|
|
What i want is if a file is opened from D:\work\New Text Document.txt ,i want to get the path as stated before not the process name notepad.exe or excel.exe or some thing.can you help me out in this.
|
|
|
|
|
You can use function _getcwd(char* buffer,int maxlen) which will give you current directory. I hope this is you are looking for.Following simple code shows you how to use it.
char* buff,buffer[255];
buff = _getcwd(NULL,0);
cout<<buff<<endl;
|
|
|
|
|
SRKSHOME wrote: You can use function _getcwd(char* buffer,int maxlen) which will give you current directory.
How does that even come close to being a helpful answer?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
If you are asking how to find the filename/path from a FILE handle then perhaps the following code will help. Unfortunately it involves usage of some advanced undocumented functions. The following code is for Windows 2000 and above and completely unsupported.
typedef LONG NTSTATUS;
#define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0 && Status < 0x3FFFFFFF)
typedef struct _IO_STATUS_BLOCK {
union {
NTSTATUS Status;
PVOID Pointer;
};
ULONG_PTR Information;
} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
typedef struct _UNICODE_STRING
{
USHORT Length;
USHORT MaximumLength;
PWSTR Buffer;
} UNICODE_STRING, *PUNICODE_STRING;
typedef enum _FILE_INFORMATION_CLASS
{
FileNameInformation=9,
} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
typedef struct _FILE_NAME_INFORMATION
{
ULONG FileNameLength;
WCHAR FileName[MAX_PATH];
} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
NTSTATUS (NTAPI *NtQueryInformationFile)(HANDLE,PIO_STATUS_BLOCK,PVOID,LONG,FILE_INFORMATION_CLASS);
CString GetFileNameFromHandle(HANDLE hFile)
{
wchar_t wszFilename[MAX_PATH];
IO_STATUS_BLOCK stb;
FILE_NAME_INFORMATION str;
*(FARPROC*)&NtQueryInformationFile = GetProcAddress(GetModuleHandle(_T("ntdll.dll")),"NtQueryInformationFile");
DWORD Status=NtQueryInformationFile(hFile,&stb,&str,MAX_PATH,FileNameInformation);
return NT_SUCCESS(Status)?CString(str.FileName, str.FileNameLength / sizeof(WCHAR)):NULL;
}
Sample MFC usage:
CFile f;
f.Open(_T("C:\\Test.txt"),CFile::modeRead,0);
HANDLE hFile = f.m_hFile;
MessageBox(GetFileNameFromHandle(hFile));
f.Close();
Best Wishes,
-David Delaune
|
|
|
|
|
#include <cstdlib>
#include <iostream>
//#include<conio>
//#include<math>
//#include<stdio>
#define NumberOfTasks 50 // easy change number of tasks
#define MaxClock 100 // easy change clock interval for tasks to run
#define MaxTaskTime 0.001 // easy change randomazing for tasking
#define NumerOfCPUs 5 // number of multiple pc's used
#define MaxQSize 10
using namespace std;
struct t
{
int id; int runprocess; int duration;
}task[NumberOfTasks];
struct c{
int idle;
int nextideltime;
}cpu[NumerOfCPUs];
struct queue{
// int Qcounter;
// int termcounter;
// int Qcounter==L;
// int empty
// { if (int L=0; Qcounter<maxqsize;l++)>
t task;
}q[MaxQSize];
int main(int argc, char *argv[])
{
int clock=0;
int qindex=0;
int i;
// cpus
for(int ik=0;ik<numerofcpus;ik++)>
{cpu[ik].idle=0;cpu[ik].nextideltime=0;}
// tasks
for(i=0;i<numberoftasks;i++)>
{
task[i].runprocess=int(MaxTaskTime*rand());
cout<<"task:"<< task[i].runprocess << "\n";
}
// system
while(clock<=MaxClock)
{
cout <<"clock:" << clock << endl;
for(int ij=0;ij<numberoftasks;ij++)>
{if(task[i].runprocess==clock)
{}
// if -- for enter the system
} // for -tasks
for(int ik=0;ik<numerofcpus;ik++)>
{if(cpu[ik].nextideltime==clock) cpu[ik].idle=0;
} // for make cpu idle
for(int ik=0;ik<numerofcpus;ik++)>
{if ( cpu[ik].idle==0 && qindex!=0)
{
}
} // for q - enter one task from q to cpu
clock++;
} //while
system("PAUSE");
return EXIT_SUCCESS;
}
here i am suppose to create a queuing and statistics box.. showing how many task get queue or terminated if queue is full... i just don't have any idea how to do that part..
help!!
|
|
|
|