C语言

SendDlgItemMessage(hdlg, IDC_COMBO2, CB_ADDSTRING, 0, (LPARAM)STR_PAPER_B4);
SendDlgItemMessage(hdlg, IDC_COMBO2, CB_ADDSTRING, 0, (LPARAM)STR_PAPER_A4);
#define STR_PAPER_B4 "B4 LAND"
#define STR_PAPER_A4 "A4 LAND"

下拉列表值

B4 LAND
A4 LAND

Windows API EnableWindow function (windows)

Enables or disables mouse and keyboard input to the specified window or control. When input is disabled, the window does not receive input such as mouse clicks and key presses. When input is enabled, the window receives all input.

EnableWindow( GetDlgItem( hdlg, IDC_CHECK1 ), flg );
这里有个checkbox 初始化的时候我让它为disabled
就这么用
当然了flg为假,也就是它的值为0就可以做到disable
GetDlgItem这个函数是得到对话框中的某一项

----------------------------------------------------------------------------------
#define LVNI_SELECTED 0x0002 ---->微软的
HWND hListWnd=GetDlgItem(hdlg, IDC_JOBLIST);
拿到ListView控件的句柄

下面看一个函数:
ListView_GetNextItem macro (Windows)
其实就是个宏
Searches for a list-view item that has the specified properties and bears the specified relationship to a specified item. You can use this macro or send the LVM_GETNEXTITEM message explicitly.

Syntax
C++
int ListView_GetNextItem(
HWND hwnd,
int iStart,
UINT flags
);
下面看看参数的用法:
第一个参数hwnd是list-view控件的句柄,句柄就好比资源的指针
第二个参数iStart是从哪一项的索引开始查找,或者就给它一个-1
如果该参数指定为-1的话to find the first item that matches the specified flags.
The specified item itself is excluded from the search.
第三个参数flags可以是LVNI_SELECTED
返回选中项的索引值

ListView_GetItemText macro (Windows)
其实就是个宏
Gets the text of a list-view item or subitem. You can use this macro or send the LVM_GETITEMTEXT message explicitly.
Syntax
C++
void ListView_GetItemText(
HWND hwnd,
int iItem,
int iSubItem,
LPTSTR pszText,
int cchTextMax
);
ListView_GetItemText(hListWnd, iItemNo, 0, szName, sizeof(szName));
第一个参数hwnd是list-view控件的句柄,句柄就好比资源的指针
第二个参数是列表项的索引
第三个参数是The index of the subitem. To retrieve the item text, set iSubItem to zero.
szName是数组名,数组名是数组的首地址,地址常量
A pointer to a buffer that receives the item or subitem text.

最后一个参数cchTextMax
Type: int
The number of characters in the pszText buffer.

Return value
No return value.

szName就是文本


http://msdn.microsoft.com/en-us/library/windows/desktop/bb775791(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/bb774863(v=vs.85).aspx
http://mrjake.blog.163.com/blog/static/10510910620123111013498/
http://blog.sina.com.cn/s/blog_6fd1884f0100t9k9.html

-------------------------------------------------------------------------------

BOOL SetParameter(HWND hdlg) {

int i = 0;
int index;
char strText[10];
char *ptr;
int count = 0;
GetDlgItemText(hdlg,IDC_EDIT1,strText,10);
while(strText[i]!='\0') {
if(strText[0]=='.'){
MessageBox(hdlg,"fault",strText,MB_ICONWARNING|MB_OK);
return FALSE;
}
if((strText[i]>='a' && strText[i]<='z') || (strText[i]>='A' && strText[i]<='Z')) {
MessageBox(hdlg,"fault",strText,MB_ICONWARNING|MB_OK);
return FALSE;
}
if(!((strText[i]>='0' && strText[i]<='9') || strText[i]=='.')) {
MessageBox(hdlg,"fault",strText,MB_ICONWARNING|MB_OK);
return FALSE;
}
if(strText[i]=='.') {
count++;
}
if(count > 1){
MessageBox(hdlg,"fault",strText,MB_ICONWARNING|MB_OK);
return FALSE;
}

i++;
}
i--;
if(count == 0) {
MessageBox(hdlg,"fault",strText,MB_ICONWARNING|MB_OK);
return FALSE;
}

ptr = strchr(strText,'.');
if(ptr)
index = ptr-strText;

if(i - index >= 2) {
MessageBox(hdlg,"fault",strText,MB_ICONWARNING|MB_OK);
return FALSE;
}

double d = atof(strText);
return TRUE;

}

--------------------------------------------------------------------------------

#include <string.h>
#include <stdio.h>

main()
{
char str[15];
char *ptr;
clrscr();
strcpy(str,"This is a string");
ptr = strchr(str,'r');
if(ptr)
printf("The character r is at position: %d\n",ptr-str);
else
printf("The character was not found\n");
}


----------------------------------------------------------------------------------

#include "stdio.h"
main()
{
int i;
char *name[100];
char *str = "hello";
clrscr();

name[0] = str;
str = "world";
name[1] = str;
for(i = 0;i < 2;i++)
printf("%s\n",name[i]);

}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值