|
CString::Find
MSDN:
// First example demonstrating
// CString::Find ( TCHAR ch )
CString s( "abcdef" );
ASSERT( s.Find( 'c' ) == 2 );
ASSERT( s.Find( "de" ) == 3 );
// Second example demonstrating
// CString::Find( TCHAR ch, int nStart )
CString str("The stars are aligned");
int n = str.Find('e', 5);
ASSERT(n == 12);
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Are these errors compile time? If so, what's the complaint about?
Do you mean "CStringt.h", or possibly "cstring"?
Steve S
|
|
|
|
|
If you are working around with a MFC project generated by VC++, there's no need to include any header file for CString. If you insist, then do:
#include <cstringt.h> // Visual Studio .NET
If you are using string, you have to include <string>. And class string is in namespace std.
Maxwell Chen
|
|
|
|
|
Thank you to all those who replied about my question I really appreciate it. So sorry about the header file... I thought there was still a need for me to add a CString header file when I intend to use its functionalities
Thanks guys
|
|
|
|
|
How to get full path to folder using SHGetPathFromIDList, or maybe in other way, but using only SHBrowseForFolder
|
|
|
|
|
|
how to get _DSpreadSheet's point from _DSpreadSheet's handle?
(class _DSpreadSheet : public COleDispatchDriver)
CButton's point can get from CButton's handle.
CButton *p;
p = (CButton *)CWnd::FromHandle(glhTargetWnd);
help me! 555555
|
|
|
|
|
Try
pYourWnd->GetControlUnknown();
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
thank you for your answer,
but my point is HWND__ and your pYourWnd is CWnd.
I can not use it.
How can I do ?
|
|
|
|
|
That is easy.
Use
CWnd *pWnd = CWnd::FromHandle(yourHWND);
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
How can I do to read the timecode in avi files before render them with DirectShow filter ?
Can you give me sample codes ?
Thank you for your answer.
Fred
|
|
|
|
|
Hi,
From my application I am launchin another exe by calling thrugh WinExec("EXE path",SW_SHOW).But the problem here is EXE is getting opened every time when I click the toolbar butto.I want to restrict this for single instance.
can anybody help me regarding this?
Bose Dayala
|
|
|
|
|
the exe you are launching do u have its code, if you do you can code in to the exe itself that it will run only one time
every time it start it can do a FindWindow(windowname) if exists exit ( or Win32 Events can be used )
if you don't have access to the exe's code than in the launching application use CreateProcess instead of winexec and use the handle to the process too determine if the exe is running or not
hope it helps
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
Hi,
thnx for quick help....I don't have its code and even ProcessID...how to get the process ID for any EXE??
thnx and regards
Bose Dayala.
ThomasKennedyBose
|
|
|
|
|
Task Manager is an example of a program that enumerates all running processes. It is implemented using data from the performance registry. The following sample code uses the EnumProcesses function to enumerate the current processes in the system. This method is easier than using the performance registry.
#include <windows.h>
#include <stdio.h>
#include "psapi.h"
void PrintProcessNameAndID( DWORD processID )
{
char szProcessName[MAX_PATH] = "unknown";
// Get a handle to the process.
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
// Get the process name.
if ( hProcess )
{
HMODULE hMod;
DWORD cbNeeded;
if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod),
&cbNeeded) )
{
GetModuleBaseName( hProcess, hMod, szProcessName,
sizeof(szProcessName) );
}
}
// Print the process name and identifier.
printf( "%s (Process ID: %u)\n", szProcessName, processID );
CloseHandle( hProcess );
}
void main( )
{
// Get the list of process identifiers.
DWORD aProcesses[1024], cbNeeded, cProcesses;
unsigned int i;
if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
return;
// Calculate how many process identifiers were returned.
cProcesses = cbNeeded / sizeof(DWORD);
// Print the name and process identifier for each process.
for ( i = 0; i < cProcesses; i++ )
PrintProcessNameAndID( aProcesses[i] );
}
The main function obtains a list of processes by using the EnumProcesses function. For each process, main calls the PrintProcessNameAndID function, passing it the process identifier. PrintProcessNameAndID in turn calls the OpenProcess function to obtain the process handle. If OpenProcess fails, the output shows only the process identifier. For example, OpenProcess fails for the Idle and CSRSS processes because their access restrictions prevent user-level code from opening them. Next, PrintProcessNameAndID calls the EnumProcessModules function to obtain the module handles. Finally, PrintProcessNameAndID calls the GetModuleBaseName function to obtain the name of the executable file.
This may help u.
/jitendra
Jitendra Pal Singh Gangwar
E-mail: jitendra_gangwar@hotmail.com
Mobile No: 09831352305
|
|
|
|
|
Task Manager is an example of a program that enumerates all running processes. It is implemented using data from the performance registry. The following sample code uses the EnumProcesses function to enumerate the current processes in the system. This method is easier than using the performance registry.
#include <windows.h>
#include <stdio.h>
#include "psapi.h"
void PrintProcessNameAndID( DWORD processID )
{
char szProcessName[MAX_PATH] = "unknown";
// Get a handle to the process.
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
// Get the process name.
if ( hProcess )
{
HMODULE hMod;
DWORD cbNeeded;
if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod),
&cbNeeded) )
{
GetModuleBaseName( hProcess, hMod, szProcessName,
sizeof(szProcessName) );
}
}
// Print the process name and identifier.
printf( "%s (Process ID: %u)\n", szProcessName, processID );
CloseHandle( hProcess );
}
void main( )
{
// Get the list of process identifiers.
DWORD aProcesses[1024], cbNeeded, cProcesses;
unsigned int i;
if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
return;
// Calculate how many process identifiers were returned.
cProcesses = cbNeeded / sizeof(DWORD);
// Print the name and process identifier for each process.
for ( i = 0; i < cProcesses; i++ )
PrintProcessNameAndID( aProcesses[i] );
}
The main function obtains a list of processes by using the EnumProcesses function. For each process, main calls the PrintProcessNameAndID function, passing it the process identifier. PrintProcessNameAndID in turn calls the OpenProcess function to obtain the process handle. If OpenProcess fails, the output shows only the process identifier. For example, OpenProcess fails for the Idle and CSRSS processes because their access restrictions prevent user-level code from opening them. Next, PrintProcessNameAndID calls the EnumProcessModules function to obtain the module handles. Finally, PrintProcessNameAndID calls the GetModuleBaseName function to obtain the name of the executable file.
This may help u.
/jitendra
|
|
|
|
|
I am doing a search for a particular directory (1).
If the directory is found then I am going to the last sub directory of 1.
Then I am listing all the files in these directory.
Pls kindly help me in this respect.
CFileFind l_fileFind;
//Find the root directory
bool l_bool = l_fileFind.FindFile(_T("D:\\Epson\\CPS"));
while(l_bool)
{
l_bool = l_fileFind.FindNextFile();
if (l_fileFind.IsDirectory())
{
//List all the files
}
}
|
|
|
|
|
Just do the whole thing again, a filefind in the new directory with \*.* at the end.
|
|
|
|
|
Anyone knows how to detect whether or not the current window is console window.
Thanx in advance...
|
|
|
|
|
HWND hwnd = ::GetForegroundWindow();
ASSERT(hwnd != NULL);
TCHAR szClass[256] = _T("");
::GetClassName(hwnd, szClass, 255);
if (_tcsicmp(szClass, _T("ConsoleWindowClass")) == 0)
{
}
else
{
}
I did not compile above code, but you should have got the main idea.
|
|
|
|
|
how do i automatically highlight a row in CListCtrl ?
(i have enabled full row select)
SetSelectionMark doesn't seem to work
|
|
|
|
|
Check out CListCtrl::SetItemState in MSDN.
|
|
|
|
|
I am really new to C++ and I dont have a clue what Im doing yet. I keep reciving the following compiler error
c:\Documents and Settings\Owner\My Documents\Visual Studio Projects\Windows Forms\Form1.h(144): error C2065: 'hInstance' : undeclared identifier The code itself is listed below. If anyone can help me I would apprecaite it very much
<code>
#pragma once
HWND hw;
MSG msg;
int status;
namespace WindowsForms
{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
public __gc class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
}
protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::Button * button1;
private: System::Windows::Forms::Button * button3;
private: System::Windows::Forms::Button * button4;
private: System::Windows::Forms::TextBox * textBox1;
private:
System::ComponentModel::Container * components;
void InitializeComponent(void)
{
this->button1 = new System::Windows::Forms::Button();
this->button3 = new System::Windows::Forms::Button();
this->button4 = new System::Windows::Forms::Button();
this->textBox1 = new System::Windows::Forms::TextBox();
this->SuspendLayout();
this->button1->Cursor = System::Windows::Forms::Cursors::Hand;
this->button1->ForeColor = System::Drawing::Color::Black;
this->button1->ImageAlign =
System::Drawing::ContentAlignment::TopCenter;
this->button1->Location = System::Drawing::Point(1, 0);
this->button1->Name = S"button1";
this->button1->Size = System::Drawing::Size(208, 38);
this->button1->TabIndex = 0;
this->button1->Text = S"Set Desktop Wallpaper";
this->button1->Click += new System::EventHandler(this, button1_Click);
this->button3->Cursor = System::Windows::Forms::Cursors::Hand;
this->button3->ForeColor = System::Drawing::Color::Black;
this->button3->Location = System::Drawing::Point(1, 38);
this->button3->Name = S"button3";
this->button3->Size = System::Drawing::Size(208, 38);
this->button3->TabIndex = 3;
this->button3->Text = S"Grand Finale";
this->button3->Click += new System::EventHandler(this,
button3_Click_1);
this->button4->ForeColor = System::Drawing::Color::Black;
this->button4->ImageAlign =
System::Drawing::ContentAlignment::BottomCenter;
this->button4->Location = System::Drawing::Point(1, 76);
this->button4->Name = S"button4";
this->button4->Size = System::Drawing::Size(208, 38);
this->button4->TabIndex = 4;
this->button4->Text = S"Exit";
this->button4->Click += new System::EventHandler(this, button4_Click);
this->textBox1->ForeColor = System::Drawing::SystemColors::HotTrack;
this->textBox1->Location = System::Drawing::Point(1, 112);
this->textBox1->Name = S"textBox1";
this->textBox1->ReadOnly = true;
this->textBox1->Size = System::Drawing::Size(208, 20);
this->textBox1->TabIndex = 5;
this->textBox1->Text = S"";
this->textBox1->TextAlign =
System::Windows::Forms::HorizontalAlignment::Center;
this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
this->ClientSize = System::Drawing::Size(210, 136);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->button4);
this->Controls->Add(this->button3);
this->Controls->Add(this->button1);
this->Cursor = System::Windows::Forms::Cursors::No;
this->FormBorderStyle =
System::Windows::Forms::FormBorderStyle::FixedToolWindow;
this->Name = S"Form1";
this->Text = S"A Little Something Just For You";
this->TransparencyKey = System::Drawing::Color::Crimson;
this->Load += new System::EventHandler(this, Form1_Load);
this->ResumeLayout(false);
}
private: System::Void Form1_Load(System::Object * sender, System::EventArgs * e)
{
}
private: System::Void button4_Click(System::Object * sender, System::EventArgs * e)
{
textBox1->Text = S"Your not getting away that easy";
}
private: System::Void button3_Click(System::Object * sender, System::EventArgs * e)
{
BOOL CALLBACK DialogProc (HWND hWnd, UINT uMsg, WPARAM
wParam, LPARAM
lParam);
hw = CreateDialog( hInstance , MAKEINTRESOURCE ( 102 ) ,NULL,
reinterpret_cast<DLGPROC>(DialogProc ));
}
private: System::Void button1_Click(System::Object * sender, System::EventArgs * e)
{
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (void*)"wallpaper.bmp", SPIF_UPDATEINIFILE |
SPIF_SENDWININICHANGE);
}
private: System::Void button3_Click_1(System::Object * sender, System::EventArgs * e)
{
}
};
}
#include <WinUser.h>
#include "stdafx.h"
#include <windows.h>
#include <stdlib.h>
#include "Form1.h"
using namespace WindowsForms;
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
System::Threading::Thread::CurrentThread->ApartmentState =
System::Threading::ApartmentState::STA;
Application::Run(new Form1());
return 0;
}
</code>
Thanks for any and all help
Draco
|
|
|
|
|
Draco0283 wrote:
#include "Form1.h" // <--- You use hInstance at here in this file.
using namespace WindowsForms;
int APIENTRY _tWinMain(HINSTANCE hInstance, // But hInstance actually is known by the compiler at this line...
HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow){ /* */ }
Maxwell Chen
|
|
|
|
|
Ok in reference to Maxwell Chen I tried several things. I moved the #include "form.h" statement and I tried to move where it calls hInstance. Everything I did brought up more problems than before. Where should it go? Thanks for your help
Draco
|
|
|
|
|